Forum Discussion
Moving average with custom calendar
Hi amaddala ,
Based on your description, you can do some steps as follows.
- Create a rank column in power query.
Duplicate the “fiscal week” column-->split it by number of characters(left 6)-->remove the unnecessary column and rename the necessary one as “week”
- Create a measure.
Measure = IF(MAX('Sheet1'[week])<=4,0,AVERAGEX(FILTER(ALL(Sheet1),[week]<SELECTEDVALUE(Sheet1[week])&&[week]>=SELECTEDVALUE(Sheet1[week])-4),[Transaction#]))
Result:
Hope that's what you were looking for.
Best Regards,
Yuna
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Your idea was helpful, but when I tried to apply this the result wasnt coming correctly. However, I created a new dax as below. It worked, but not sure what was the difference between your logic and mine.
But when I try to add any other dimension to this, the value remains the same.
- Anonymous5 years agoNot applicable
Hi amaddala ,
Could you please tell me what went wrong? Could you share some screenshots around the issue please? This is not helping much.
Add error screenshot as well which you are facing.
I tested it again with new data, and there were no errors.
You said that you want to calculate the moving average of the previous four weeks, but the formula you gave is the moving average of the previous six weeks.
Maybe I'm not getting what actually you are trying to do.
Best Regards,
Yuna
- amaddala5 years ago
Helper I
Thank you, I have just used 6 weeks instead of 4 with the same logic you shared as my business requirement changed. Below is the screenshot for what I am seeing with my code vs yours.
- Anonymous5 years agoNot applicable