Edit: changed to AVERAGEX.
@Swhs24 I have done something similar, so this may work for you.
First you create your 7 day moving average for each.
7 Avg Daily = VAR LastDate_ =
LASTDATE ( ‘Date’[Date] )
RETURN
AVERAGEX (
CALCULATETABLE (
VALUES ( ‘Date’[Date] ),
FILTER (
ALL ( ‘Date’ ),
‘Date’[Date] <= LastDate_
&& ‘Date’[Date] > DATEADD ( LastDate_, -7, DAY )
)
),
[Sales]
)
7 Avg Weekly = VAR LastDate_ =
LASTDATE ( ‘Date’[Date] )
RETURN
AVERAGEX (
CALCULATETABLE (
VALUES ( ‘Date’[WeekOf] ),
FILTER (
ALL ( ‘Date’ ),
‘Date’[Date] <= LastDate_
&& ‘Date’[Date] > DATEADD ( LastDate_, -49, DAY )
)
),
[Sales]
)
7 Avg Monthly = VAR LastDate_ =
LASTDATE ( ‘Date’[Month] )
RETURN
AVERAGEX (
CALCULATETABLE (
VALUES ( ‘Date’[Month] ),
FILTER (
ALL ( ‘Date’ ),
‘Date’[Month] <= LastDate_
&& ‘Date’[Month] > DATEADD ( LastDate_, -7, MONTH )
)
),
[Sales]
)
7 Avg Yearly = VAR LastDate_ =
MAX ( ‘Date’[Year] )
RETURN
AVERAGEX (
CALCULATETABLE (
VALUES ( ‘Date’[Year] ),
FILTER (
ALL ( ‘Date’ ),
‘Date’[Year] <= LastDate_
&& ‘Date’[Year] > LastDate_ - 7
)
),
[Sales]
)
Then a measure to ensure you are using the right one depending on what you are looking at:
7 Avg Period = SWITCH (
TRUE (),
ISBLANK ( SELECTEDVALUE ( ‘Date’[Date] ) ) = FALSE (), [7 Avg Daily],
ISBLANK ( SELECTEDVALUE ( ‘Date’[WeekOf] ) ) = FALSE (), [7 Avg Weekly],
ISBLANK ( SELECTEDVALUE ( ‘Date’[Month] ) ) = FALSE (), [7 Avg Monthly],
ISBLANK ( SELECTEDVALUE ( ‘Date’[Year] ) ) = FALSE (), [7 Avg Yearly],
BLANK ()
)
Then you can use it like this:
Here is the PBIX for you to reference:
2021-03-27 Rolling Average multiple periods.pbix (178.0 KB)
Respectfully,
DataZoe