Decompose comparable SKU revenue change into price and volume
Original fictional practice · CC BY 4.0 · 2026-11-11

TASK
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.

OUTPUT
sku, volume_effect, price_effect, revenue_change

RULES
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.

FIELD DICTIONARY
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.

METHOD
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.

COMMON WRONG TURN
A revenue difference alone cannot explain whether volume or selling price caused the change.

RESULT CHECK
For the first output record, sku = A; volume_effect = 200; price_effect = 240; revenue_change = 440.

Use setup.sql in a fresh SQLite database and run your own SELECT or WITH. reference.sql and expected.csv contain the full worked answer. All CSVs have UTF-8 headers; empty output fields represent NULL. The browser executes SQLite, not Excel formulas. No spreadsheet function engine is claimed.
