Kpi dashboard design

From findscripter/everything-skills · View interactive version

Kpi dashboard design is an AI agent skill from the GitHub repository findscripter/everything-skills. 当需要设计 KPI 仪表盘、为高管/部门挑选关键指标、规划布局或编写指标计算时使用;产出指标分层框架、布局模式与可执行的 SQL/Streamlit 代码;不适用于与指标无关的通用 BI 或纯报表导出。触发词:KPI、仪表盘、dashboard、关键指标、北极星指标、指标体系、MRR、留存、cohort、metrics、KPI dashboard、executive dashboard

How to use this skill

Skill file

何时使用

适用:

不该用(负边界):

步骤

  1. 明确目标与受众,按三层框架定位指标层级(决定更新频率和颗粒度):

| 层级 | 关注点 | 更新频率 | 受众 |

| --- | --- | --- | --- |

| 战略 Strategic | 长期目标 | 月/季 | 高管 |

| 战术 Tactical | 部门目标 | 周/月 | 经理 |

| 运营 Operational | 日常执行 | 实时/日 | 团队 |

  1. 用 SMART 校验每个 KPI:Specific 定义清晰、Measurable 可量化、Achievable 目标现实、Relevant 对齐目标、Time-bound 有明确周期。剔除虚荣指标。
  2. 按部门选取指标(销售:MRR/ARR/ARPU、Win Rate、销售周期;市场:CAC/CPA、转化率、ROI/回本期;产品:DAU/MAU、留存/流失、NPS/CSAT;财务:毛利/净利、流动比率、人均营收)。
  3. 设计层级结构:高管摘要 1 页(4-6 个头条 KPI + 趋势 + 告警)→ 部门视图 → 明细下钻/根因分析。
  4. 选布局模式落地(见示例):高管摘要 / SaaS 指标 / 实时运营三类。
  5. 实现指标计算(SQL)与展示(Streamlit + Plotly),按指标频率设置刷新。

指令

示例

高管摘要布局(核心思想:顶部一排头条卡片带趋势箭头,中部趋势/构成图,底部告警条):

┌──────────────────────────────────────────────┐
│ EXECUTIVE DASHBOARD              [Date Range ▼]│
├──────────┬──────────┬──────────┬──────────────┤
│ REVENUE  │ PROFIT   │ CUSTOMERS│ NPS          │
│ $2.4M ▲12%│ $450K ▲8%│ 12,450 ▲15%│ 72 ▲5pts  │
├──────────┴──────────┴──────────┴──────────────┤
│ Revenue Trend (line)   │ Revenue by Product(pie)│
├──────────────────────────────────────────────┤
│ 🔴 Churn 超阈值(>5%)   🟡 工单量高于均值20%      │
└──────────────────────────────────────────────┘

指标计算(SQL,MRR 及环比增长,按订阅周期折算到月):

WITH mrr_calculation AS (
  SELECT DATE_TRUNC('month', billing_date) AS month,
    SUM(CASE subscription_interval
          WHEN 'monthly'   THEN amount
          WHEN 'yearly'    THEN amount / 12
          WHEN 'quarterly' THEN amount / 3
        END) AS mrr
  FROM subscriptions WHERE status = 'active'
  GROUP BY DATE_TRUNC('month', billing_date)
)
SELECT month, mrr,
  LAG(mrr) OVER (ORDER BY month) AS prev_mrr,
  (mrr - LAG(mrr) OVER (ORDER BY month))
    / LAG(mrr) OVER (ORDER BY month) * 100 AS growth_pct
FROM mrr_calculation;

CAC(营销支出 / 当月新增付费客户):SUM(marketing_spend) / NULLIF(COUNT(new_customers), 0),按月聚合;cohort 留存用 EXTRACT(MONTH FROM age(activity_month, cohort_month)) 计算注册后第 N 月活跃占比。

展示(Streamlit + Plotly,KPI 卡片 + 趋势/构成图 + cohort 热力图 + 告警):

import streamlit as st, pandas as pd
import plotly.express as px, plotly.graph_objects as go
st.set_page_config(page_title="KPI Dashboard", layout="wide")

def metric_card(label, value, delta, prefix="", suffix=""):
    arrow = "▲" if delta >= 0 else "▼"
    st.metric(label, f"{prefix}{value:,.0f}{suffix}",
              f"{arrow} {abs(delta):.1f}%")

c1, c2, c3, c4 = st.columns(4)
with c1: metric_card("Revenue", 2400000, 12.5, prefix="$")
with c2: metric_card("Customers", 12450, 15.2)
with c3: metric_card("NPS", 72, 5.0)
with c4: metric_card("Churn", 4.2, -0.8, suffix="%")

# 趋势用 px.line(line_shape='spline', markers=True)
# 构成用 px.pie(hole=0.4)
# cohort 用 go.Heatmap(colorscale='Blues', texttemplate='%{text}%')
for a in [("error","Churn 超阈值(>5%)"), ("warning","工单量高于均值20%")]:
    (st.error if a[0]=="error" else st.warning)(a[1])

注意事项

互见


本条采编自 sickn33/antigravity-awesome-skills(MIT)。

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.