Forum Discussion
Rolling average with filter
- 5 years ago
Hi arutsjak90 -
Make sure you have a calendar table, linked to the "Fixed Date" column in your table, and then try this code
Rolling 3 Mo Avg = VAR __ThisMonth = MAX ( COGS[FixedDate] ) VAR __3MoBack = EDATE ( __ThisMonth, -3 ) + 1 RETURN CALCULATE ( SUM ( COGS[Total COGS] ), ALLEXCEPT ( COGS, COGS[Plant] ), DATESBETWEEN ( DateTab[Date], __3MoBack, __ThisMonth ) ) / 3Hope this helps
David
I have sent it via private message
Please post the link in the thread, not PM, in case others want to look at it or help.
That being said, you did not create the proper relationships in your model, as instructed. This will cause the measure code to not work correctly.
Link "COSG[Fixed Date]" to DateTab[Date].
Hope this helps
David
- arutsjak905 years ago
Helper I
https://drive.google.com/drive/folders/16GoTloQOeYLuvgu6eMl6M0LSgKA4iJzj?usp=sharing
Thank you!
Is it possible to create calculated column instead of measure?
- dedelman_clng5 years ago
Community Champion
I would not recommend creating it as a calcaulted column. Measures can be used in mostly the same way as columns and are more dynamic.
If you run into an issue using the measure in further calculations, please start a new thread instead of continuing this one.
David