Forum Discussion
apatwal
Helper III
4 years agoIssue in Rolling 4 Week Average
Hi, I am facing calculation issue in Rolling 4 Week Average; Margin (Measure) Rolling 4 Wk Average (Measure) Please find below DAX used: Rolling 4 Wk Average= IF( ISBLANK...
- 4 years ago
Hi apatwal
Here's the answerMargin 4 Week Rolling Average = VAR RelevantWeeks = CALCULATETABLE( VALUES('Calendar'[WeekEndingDate]), DATESBETWEEN( 'Calendar'[Date], MAX('Calendar'[Date]) - 28, MAX('Calendar'[Date]) ), REMOVEFILTERS('Calendar') ) RETURN AVERAGEX( RelevantWeeks, [Total Margin] )
littlemojopuppy
Community Champion
4 years agoHi apatwal I'm not understanding why you're ranking weeks as part of this calculation. If you have a date table (and you do) and it is marked as one, your calculation should be fairly simple unless I'm missing something?
VAR RelevantWeeks =
CALCULATETABLE(
VALUES(DateTable[Week End Date]),
DATESBETWEEN(
DateTable[Date],
MAX(DateTable[Date]) - 28,
MAX(DateTable[Date])
)
)
RETURN
AVERAGEX(
RelevantWeeks,
[Margin]
)littlemojopuppy
Community Champion
4 years agoHi apatwal what's the issue? You never said what's incorrect?
- apatwal4 years ago
Helper III
Sorry I missed out the screenshots.
Looks like may be I am missing something:
Thanks...
- littlemojopuppy4 years ago
Community Champion
Hi apatwal you're not having it average anything. After the closing parenthesis for DATESBETWEEN, add a comma and then [Margin] (or the name of your measure). That should take care of it
- apatwal4 years ago
Helper III
Thanks for your reply!
Ooops that was my small mistake..
But Now I am facing another issue