You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否在Superset中创建Period-over-Period Charts以实现多周期数据对比?

Absolutely! Apache Superset fully supports creating Period-over-Period (PoP) charts to compare data across different time frames—whether you need year-over-year, week-over-week, month-over-month, or even custom period comparisons like the revenue example you mentioned. From my experience working with Superset, there are two main approaches to build these charts, depending on your needs:

How to Create Period-over-Period Charts in Apache Superset

1. Use Superset's Native Time Comparison Feature (Quick & Easy)

If you want a straightforward setup without writing custom SQL, Superset has a built-in tool for this:

  • Start building your preferred chart type (bar, line, or area charts work best for comparisons)
  • Navigate to the Time section in the chart configuration panel
  • Look for the Compare dropdown (labeled "Period Over Period" in some versions)
  • Select your desired comparison:
    • Year-over-Year (YoY): Compare the current period to the same window in the prior year
    • Month-over-Month (MoM): Compare this month's data to last month's
    • Week-over-Week (WoW): Compare the current week to the previous one
    • Custom periods: Define your own ranges (e.g., last 30 days vs. the 30 days before that)
  • Once selected, Superset will auto-generate two series in your chart: one for the current period, and one for the comparison period—ready for you to style and label.

2. Custom SQL for Advanced, Tailored Comparisons

If you need more control (like comparing non-standard fiscal periods or calculating percentage changes), build the comparison logic directly in your dataset query. For example, to compare annual revenue side-by-side:

WITH current_year_revenue AS (
    SELECT
        DATE_TRUNC('quarter', order_date) AS quarter,
        SUM(total_revenue) AS current_rev
    FROM sales_data
    WHERE order_date BETWEEN '2023-01-01' AND '2023-12-31'
    GROUP BY 1
),
prior_year_revenue AS (
    SELECT
        DATE_TRUNC('quarter', order_date) AS quarter,
        SUM(total_revenue) AS prior_rev
    FROM sales_data
    WHERE order_date BETWEEN '2022-01-01' AND '2022-12-31'
    GROUP BY 1
)
SELECT
    c.quarter,
    c.current_rev,
    p.prior_rev,
    ROUND(((c.current_rev - p.prior_rev)/p.prior_rev)*100, 2) AS yoy_growth_pct
FROM current_year_revenue c
JOIN prior_year_revenue p ON c.quarter = DATE_ADD(p.quarter, INTERVAL 1 YEAR)
ORDER BY c.quarter

Use this query as your dataset in Superset, then build a grouped bar chart or dual-axis line chart to visualize the side-by-side revenue figures and growth percentage.

3. Quick Visualization Tips

  • Stick to chart types that make comparisons clear: grouped bars for side-by-side period values, line charts for tracking trend changes across periods.
  • Use distinct color coding (e.g., blue for current year, gray for prior year) to avoid confusion.
  • Add value labels or annotations to highlight key differences (like a 15% YoY revenue jump in Q3).

You can absolutely generate the exact chart you described—showing current year revenue alongside the corresponding metrics from an earlier year—using either of these methods.

内容的提问来源于stack exchange,提问作者Maki

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 07:32:44