Forum Discussion
Anonymous
4 years agoNot applicable
Rolling Sum for 4 previous rows based on ID
Hi,
I'm looking to calculate the rolling sum for the current and the last 4 rows , based on an ID column.
Any help please ?
Anonymous , Column or measure
new column =
Sumx(filter((Table), Table[ID] <= earlier(Table[ID]) && Table[ID] >= earlier(Table[ID]) -4) , [sales] )
new measure =
Sumx(filter(allselected(Table), Table[ID] <= Max(Table[ID]) && Table[ID] >= max(Table[ID]) -4) , [sales] )
2 Replies
- amitchandak
Super User
Anonymous , Column or measure
new column =
Sumx(filter((Table), Table[ID] <= earlier(Table[ID]) && Table[ID] >= earlier(Table[ID]) -4) , [sales] )
new measure =
Sumx(filter(allselected(Table), Table[ID] <= Max(Table[ID]) && Table[ID] >= max(Table[ID]) -4) , [sales] )- AnonymousNot applicable
Thankyou so much for this solution, it helps to resolved my issues.