Forum Discussion
How to calculate rolling 5 week average ?
- Anonymous2 years ago
Hi Sergii24 ,thanks for the quick reply, I'll add further.
Hi newlearnpbi123 ,
The Table data is shown below:
Please follow these steps:
1. Use the following DAX expression to create a columnWeeknumber = WEEKNUM([Date],2)2. Use the following DAX expression to create a measure
Measure = VAR _a = SELECTEDVALUE('Table'[Weeknumber]) VAR _b = CALCULATE(AVERAGE('Table'[Unit]),FILTER(ALL('Table'),'Table'[Weeknumber] <= _a && 'Table'[Weeknumber] >= _a -4 )) RETURN _b3.Final output
You can upload sample pbix used by for the example here. If same calculation provides blank(), than there is something in your semantic model that should be taken into account. However, I hope that by having this pbix as example and making research online you can find the answer! If not, please share your pbix sample with your semantic model.
- newlearnpbi1232 years agoHelper I
sorry i cannot upload the pbi file for the obvious reasons,
i just have 3 column one is category and other is weeks and other is unit ( above screenshot )any help appreciated sergii, thank you.
- Anonymous2 years agoNot applicable
Hi Sergii24 ,thanks for the quick reply, I'll add further.
Hi newlearnpbi123 ,
The Table data is shown below:
Please follow these steps:
1. Use the following DAX expression to create a columnWeeknumber = WEEKNUM([Date],2)2. Use the following DAX expression to create a measure
Measure = VAR _a = SELECTEDVALUE('Table'[Weeknumber]) VAR _b = CALCULATE(AVERAGE('Table'[Unit]),FILTER(ALL('Table'),'Table'[Weeknumber] <= _a && 'Table'[Weeknumber] >= _a -4 )) RETURN _b3.Final output