Forum Discussion
Anonymous
5 years agoNot applicable
How to calculate roll up average using dax
Hi I have a dataset like this, the date difference between each sprint is 14 days. Team DateBegin Sprint Points
Team1 1/2/2021 Sprint1 30
Team1 1/16/2021 Sprint2 ...
- 5 years ago
Hi Anonymous ,
First you need to create index column by group:
#"Grouped Rows" = Table.Group(#"Removed Columns1", {"Team"}, {{"Count", each _, type table [Team=nullable text, DateBegin=nullable date, Sprint=nullable text, Points=nullable number]}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count],"index",1)), #"Removed Columns2" = Table.RemoveColumns(#"Added Custom",{"Team", "Count"}), #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns2", "Custom", {"Team", "DateBegin", "Sprint", "Points", "index"}, {"Custom.Team", "Custom.DateBegin", "Custom.Sprint", "Custom.Points", "Custom.index"}), #"Renamed Columns1" = Table.RenameColumns(#"Expanded Custom",{{"Custom.Team", "Team"}, {"Custom.DateBegin", "DateBegin"}, {"Custom.Sprint", "Sprint"}, {"Custom.Points", "Points"}, {"Custom.index", "index"}})Then you can use the following measure:
Measure = MAX('Table'[Points])- AVERAGEX(TOPN(3,FILTER(ALLEXCEPT('Table','Table'[Team]),'Table'[index] <MAX('Table'[index])),'Table'[index],DESC),'Table'[Points])Please refer to the pbix file.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
amitchandak
Super User
5 years agoAnonymous , Create a rank on sprint begindate ( create a separate table with sprint and begin date)
sprint rank = RANKX(all('sprint '),'Dsprint ate'[begindate ],,ASC,Dense)
measures
Last 3 sprint = CALCULATE(sum('Table'[points]), FILTER(ALL('sprint '),'sprint '[sprint Rank]>=max('sprint '[sprint Rank])-3 && 'sprint '[sprint Rank]<=max('sprint '[sprint Rank])))