Explainable business reporting · Original fictional data · Free files and full answers
Decompose comparable SKU revenue change into price and volume
For SKUs present in both periods aggregate units and use their single supplied price per period. Volume effect=(q2-q1)*p1; price effect=q2*(p2-p1). Return sku,volume_effect,price_effect,revenue_change; sort sku. Exclude new SKU D from comparable decomposition.
Use this fixed business case to build a checked CSV and a replayable SQL handoff. No account required. Scenario datasets are shared across related exercises; each exercise has its own decision and output contract.
Your output contract
- For SKUs present in both periods aggregate units and use their single supplied price per period. Volume effect=(q2-q1)*p1; price effect=q2*(p2-p1). Return sku,volume_effect,price_effect,revenue_change; sort sku. Exclude new SKU D from comparable decomposition.
- Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
- These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.
Return columns exactly as sku, volume_effect, price_effect, revenue_change. Sort order follows the task. Output has 3 rows; an empty CSV field means NULL.
Source data
sales
7 source rows · Download sales CSV
| id INTEGER | sku TEXT | channel TEXT | period INTEGER | qty INTEGER | price INTEGER | cost INTEGER | returned INTEGER |
|---|---|---|---|---|---|---|---|
| 1 | A | search | 1 | 10 | 100 | 60 | 1 |
| 2 | B | 1 | 5 | 200 | 150 | 0 | |
| 3 | C | social | 1 | 4 | 300 | 200 | 1 |
| 4 | A | search | 2 | 12 | 120 | 65 | 2 |
| 5 | B | 2 | 4 | 190 | 150 | 1 | |
| 6 | C | search | 2 | 6 | 280 | 210 | 0 |
| 7 | D | social | 2 | 3 | 500 | 450 | 0 |
touches
6 source rows · Download touches CSV
| customer TEXT | minute INTEGER | channel TEXT |
|---|---|---|
| U1 | 0 | search |
| U1 | 0 | |
| U1 | 5 | social |
| U2 | 1 | social |
| U2 | 3 | search |
| U3 | 2 |
funnel
10 source rows · Download funnel CSV
| user TEXT | minute INTEGER | step TEXT |
|---|---|---|
| U1 | 0 | visit |
| U1 | 2 | cart |
| U1 | 5 | buy |
| U2 | 0 | buy |
| U2 | 2 | visit |
| U2 | 4 | cart |
| U3 | 1 | visit |
| U3 | 1 | buy |
| U4 | 1 | visit |
| U4 | 2 | cart |
Field dictionary and schema
sales: id INTEGER — Stable source record identifier; not a row position. sku TEXT — Literal business key or category label. Match exactly and retain NULL where present. channel TEXT — Literal business key or category label. Match exactly and retain NULL where present. period INTEGER — Reporting period label1 or2, not an elapsed-time measurement. qty INTEGER — Physical quantity; multiply through assembly paths when the task requires it. price INTEGER — Selling price in integer cents per physical unit. cost INTEGER — Acquisition cost in integer cents per physical unit. returned INTEGER — Number of physically returned units. touches: customer TEXT — Literal business key or category label. Match exactly and retain NULL where present. minute INTEGER — Elapsed UTC minute from the fictional scenario origin. channel TEXT — Literal business key or category label. Match exactly and retain NULL where present. funnel: user TEXT — Literal business key or category label. Match exactly and retain NULL where present. minute INTEGER — Elapsed UTC minute from the fictional scenario origin. step TEXT — Literal business key or category label. Match exactly and retain NULL where present.
A method you can reuse
- For SKUs present in both periods aggregate units and use their single supplied price per period. Volume effect=(q2-q1)*p1; price effect=q2*(p2-p1). Return sku,volume_effect,price_effect,revenue_change; sort sku. Exclude new SKU D from comparable decomposition.
- For the first output record, sku = A; volume_effect = 200; price_effect = 240; revenue_change = 440.
- Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.
Watch for this wrong turn
A revenue difference alone cannot explain whether volume or selling price caused the change.
Run and check in SQLite
Your SQL runs locally in the existing SQLite worker. The checker compares every column, row, type, value and row order with this fixed output. It accepts equivalent SELECT or WITH queries. Browser storage keeps your SQL on this device when available.
Complete worked SQL and expected output
WITH x AS (SELECT sku,MAX(CASE WHEN period=1 THEN qty END) q1,MAX(CASE WHEN period=2 THEN qty END) q2,MAX(CASE WHEN period=1 THEN price END) p1,MAX(CASE WHEN period=2 THEN price END) p2 FROM sales GROUP BY sku) SELECT sku,(q2-q1)*p1 volume_effect,q2*(p2-p1) price_effect,q2*p2-q1*p1 revenue_change FROM x WHERE q1 IS NOT NULL AND q2 IS NOT NULL ORDER BY sku;
"sku","volume_effect","price_effect","revenue_change" "A","200","240","440" "B","-200","-40","-240" "C","600","-120","480"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects