I am trying to create a report, which should give weekly data but also a column for rolling 6 months till the last month and the same period last year.
I am able to calculate the rolling average using the formula below:
6 months rolling =
VAR period_end =
CALCULATE(
MAX('Dimensions'[Month Start Date]),
FILTER(
ALL('Dimensions'[Year Week]),
'Dimensions'[Year Week]=SELECTEDVALUE('Dimensions'[Year Week])
)
)
VAR period_till =
FIRSTDATE(
DATESINPERIOD(
'Dimensions'[Month Start Date],
period_end,
-1,
MONTH
)
)
VAR period_start =
FIRSTDATE(
DATESINPERIOD(
'Dimensions'[Month Start Date],
period_till,
-6,
MONTH
)
)
RETURN
CALCULATE(
SUM(Total_Sales),
DATESBETWEEN(
[Month Start Date],
period_start,
period_till
)
)
The data comes up fine but as soon as i put a slicer on the [Year Week], it starts giving the weekly data, rather than Rolling average.
I think i need to use ALL filter but my efforts haven't paid off on it too yet. Appreciate any help on this.
Report structure is like this :
Category
Current_Week_Data
Previous year same week data
difference %
rolling 6 months (this year - previous 6 year 6 months /previous year 6 months)