Forum Discussion
Anonymous
4 years agoNot applicable
Rolling average for the last 4 weeks average value.
Hi All, Need your support. I want to calculate moving/rolling average value of a KPI for the last 4 weeks average values using DAX. I have simply calculated the values in excel for the referenc...
- 4 years ago
You'll need a week commencing column on your date table, or something similar, then
Weekly Avg = VAR currentWC = MAX ( 'Date'[W / C] ) VAR startDate = currentWC - 35 VAR endDate = currentWC - 1 RETURN AVERAGEX ( ADDCOLUMNS ( CALCULATETABLE ( SUMMARIZE ( 'Date', 'Date'[W / C] ), DATESBETWEEN ( 'Date'[Date], startDate, endDate ) ), "@val", [Measure] ), [@val] )
johnt75
Super User
4 years agoYou'll need a week commencing column on your date table, or something similar, then
Weekly Avg =
VAR currentWC =
MAX ( 'Date'[W / C] )
VAR startDate = currentWC - 35
VAR endDate = currentWC - 1
RETURN
AVERAGEX (
ADDCOLUMNS (
CALCULATETABLE (
SUMMARIZE ( 'Date', 'Date'[W / C] ),
DATESBETWEEN ( 'Date'[Date], startDate, endDate )
),
"@val", [Measure]
),
[@val]
)