Hi @Andrea,
Thanks for the further description.
If that’s the case, I think you would need Level Aware Aggregations (LAA) here.
The easiest way that I can think of right now:
- Extract just the week out from your “Week” column using split or right function - namely “Week Number”
- Get the latest year in your dataset, namely “Get the latest year in the dataset”:
extract("YYYY",maxOver({Order Date - New},[],PRE_AGG))
- Compute sales for current year, namely “Weekly Sales CY”:
ifelse(extract("YYYY",{Order Date - New})={10.0 Get the latest year in the dataset},Sales,0)
- Compute sales for previous year, namely “Weekly Sales PY”:
ifelse(extract("YYYY",{Order Date - New})={10.0 Get the latest year in the dataset}-1,Sales,0)
- Compute YoY Difference:
(sum({10.2 Weekly Sales CY})-sum({10.3 Weekly Sales PY}))/sum({10.3 Weekly Sales PY})
Outcome:
To understand more about LAA: