HomeCourseModule 14 › User story: a refreshing dashboard sheet

User story: a refreshing dashboard sheet

Module 14 · Scenario: Data & Business Analyst10 min readIntermediate

What you'll learn

  • Build multiple analyses against a single source
  • Use =PY() so the dashboard refreshes on data change
  • Lay out the dashboard for at-a-glance reading

The story

Marcus's manager wants a single Excel file she can open every morning and see: today's revenue, week-on-week, top 5 products, top 5 stores, anomaly count.

The structure

The =PY() cells

# Tile 1: Yesterday's revenue
=PY(
df = xl("Data!A1:F100000", headers=True)
df["date"] = pd.to_datetime(df["date"])
y = df[df["date"].dt.date == (pd.Timestamp.today().date() - pd.Timedelta(days=1))]
f"${y['revenue'].sum():,.0f}"
)

# Tile 2: Week-on-week
=PY(
df = xl("Data!A1:F100000", headers=True)
df["date"] = pd.to_datetime(df["date"])
this7 = df[df["date"] >= pd.Timestamp.today() - pd.Timedelta(days=7)]["revenue"].sum()
prev7 = df[(df["date"] < pd.Timestamp.today() - pd.Timedelta(days=7)) &
           (df["date"] >= pd.Timestamp.today() - pd.Timedelta(days=14))]["revenue"].sum()
f"{(this7/prev7 - 1)*100:+.1f}%"
)

# Tile 3: Top 5 products
=PY(
df = xl("Data!A1:F100000", headers=True)
df.groupby("product")["revenue"].sum().nlargest(5)
)

# Tile 4: Top 5 stores
=PY(
df = xl("Data!A1:F100000", headers=True)
df.groupby("store")["revenue"].sum().nlargest(5)
)

# Tile 5: Anomaly count
=PY(
df = xl("Data!A1:F100000", headers=True)
daily = df.groupby(pd.to_datetime(df["date"]).dt.date)["revenue"].sum()
mu, sd = daily.mean(), daily.std()
int(((daily - mu).abs() > 2*sd).sum())
)

Lay it out

Put the small tiles (revenue, WoW, anomaly count) in big bold cells across the top. Put the Top 5 lists in the middle. Add a single chart at the bottom: =PY() returning a line chart of the last 30 days.

💡 Refresh discipline
The dashboard auto-recalculates when the Data sheet changes. Tell stakeholders to only edit the Data sheet and nothing else.

Key takeaways

  • Dashboards are a stack of =PY() tiles, each producing one number or one table.
  • Keep the data in a separate sheet so the dashboard layout is stable.
  • Aim for one screen — if you have to scroll, it's a report, not a dashboard.

Add a tile

Add a sixth tile: yesterday's conversion rate vs the trailing 30-day average. Format as "X.XX% (Y.Y pp vs avg)".

📹 Video walkthrough
A video walkthrough of this lesson will be embedded here. Until then, the written walkthrough above mirrors what the video will cover step-for-step.