In many real-world scenarios, data doesn’t come from a single source, it’s often distributed across multiple entities like stores, regions, or departments. To make meaningful decisions, we need to aggregate and compare trends over time, rather than looking at isolated records.
In this tutorial, we’ll learn how to create a multi-line time series chart in Apache Superset using a slightly more realistic dataset that includes multiple stores contributing to daily revenue and expenses.
Use Case: Revenue vs Expenses Across Multiple Stores
Imagine you are analyzing financial performance across different stores. Each store reports its daily revenue and expenses, and your goal is to understand:
· Overall business performance over time
· Whether revenue is consistently higher than expenses
· Trends in profitability across days
Instead of analyzing each store separately, we’ll aggregate the data by date to get a unified view of performance.
store_revenue.csv
date,store_id,revenue,expenses 2026-04-01,S1,2000,1200 2026-04-01,S2,3000,2000 2026-04-02,S1,2500,1400 2026-04-02,S2,2700,1600 2026-04-03,S1,2200,1300 2026-04-03,S2,2600,1800 2026-04-04,S1,3000,1700 2026-04-04,S2,3000,1800 2026-04-05,S1,3200,1900 2026-04-05,S2,3000,1800 2026-04-06,S1,2800,1500 2026-04-06,S2,3000,1900 2026-04-07,S1,3500,2000 2026-04-07,S2,3000,2000 2026-04-08,S1,3600,2100 2026-04-08,S2,3200,2100 2026-04-09,S1,3400,2000 2026-04-09,S2,3100,1900 2026-04-10,S1,3700,2200 2026-04-10,S2,3300,2100 2026-04-11,S1,3900,2300 2026-04-11,S2,3500,2200 2026-04-12,S1,4000,2400 2026-04-12,S2,3600,2300 2026-04-13,S1,4200,2500 2026-04-13,S2,3700,2400 2026-04-14,S1,4100,2400 2026-04-14,S2,3600,2300 2026-04-15,S1,4300,2600 2026-04-15,S2,3800,2500 2026-04-16,S1,4400,2700 2026-04-16,S2,3900,2600 2026-04-17,S1,4500,2800 2026-04-17,S2,4000,2700 2026-04-18,S1,4600,2900 2026-04-18,S2,4100,2800 2026-04-19,S1,4700,3000 2026-04-19,S2,4200,2900 2026-04-20,S1,4800,3100 2026-04-20,S2,4300,3000 2026-04-21,S1,4900,3200 2026-04-21,S2,4400,3100 2026-04-22,S1,5000,3300 2026-04-22,S2,4500,3200 2026-04-23,S1,5100,3400 2026-04-23,S2,4600,3300 2026-04-24,S1,5200,3500 2026-04-24,S2,4700,3400 2026-04-25,S1,5300,3600 2026-04-25,S2,4800,3500 2026-04-26,S1,5400,3700 2026-04-26,S2,4900,3600 2026-04-27,S1,5500,3800 2026-04-27,S2,5000,3700 2026-04-28,S1,5600,3900 2026-04-28,S2,5100,3800 2026-04-29,S1,5700,4000 2026-04-29,S2,5200,3900 2026-04-30,S1,5800,4100 2026-04-30,S2,5300,4000 2026-05-01,S1,6000,4200 2026-05-01,S2,5500,4100 2026-05-02,S1,6100,4300 2026-05-02,S2,5600,4200 2026-05-03,S1,6200,4400 2026-05-03,S2,5700,4300 2026-05-04,S1,6300,4500 2026-05-04,S2,5800,4400 2026-05-05,S1,6400,4600 2026-05-05,S2,5900,4500 2026-05-06,S1,6500,4700 2026-05-06,S2,6000,4600 2026-05-07,S1,6600,4800 2026-05-07,S2,6100,4700 2026-05-08,S1,6700,4900 2026-05-08,S2,6200,4800 2026-05-09,S1,6800,5000 2026-05-09,S2,6300,4900 2026-05-10,S1,7000,5200 2026-05-10,S2,6500,5100 2026-05-11,S1,7100,5300 2026-05-11,S2,6600,5200 2026-05-12,S1,7200,5400 2026-05-12,S2,6700,5300 2026-05-13,S1,7300,5500 2026-05-13,S2,6800,5400 2026-05-14,S1,7400,5600 2026-05-14,S2,6900,5500 2026-05-15,S1,7500,5700 2026-05-15,S2,7000,5600 2026-05-16,S1,7600,5800 2026-05-16,S2,7100,5700 2026-05-17,S1,7700,5900 2026-05-17,S2,7200,5800 2026-05-18,S1,7800,6000 2026-05-18,S2,7300,5900 2026-05-19,S1,7900,6100 2026-05-19,S2,7400,6000 2026-05-20,S1,8000,6200 2026-05-20,S2,7500,6100
Follow below step-by-step procedure to build a Multi-line chart.
Step 1: Upload store_revenue.csv file to Superset.
Data -> Upload CSV to database
· Upload store_revenue.csv file
· Specify database and schema where you want to upload the csv file
· Give table name as store_revenue
Expand Columns section.
· Select all the columns to columns to read section
· Set Column data types to {"date": "datetime64[ns]", "store_id": "string", "revenue" : "float32", "expenses" : "float32"}
Click on Upload button to upload the csv file to store_revenue table.
Navigate to Datasets listing page, you can able to see the store_revenue dataset.
Step 2: Create Multi line chart.
Click on store_revenue dataset, you will be taken to chart configuration page.
Click on the link ‘view all charts’.
Select Line Chart.
Click on Select button. You will be taken to line chart configuration page.
Drag and drop date column to X-axis
Drag and drop revenue column to Metrics section and choose aggregate as SUM.
Drag and drop expenses column to Metrics section and choose aggregate as SUM.
Click on ‘Create chart’ button to draw the chart.
Save the chart. That’s it, you're good to go.
Previous Next Home








No comments:
Post a Comment