Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not 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.

mazer_0-1638797928087.png

Any help please ? 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
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] )

View solution in original post

2 REPLIES 2
amitchandak
Super User
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] )

Thankyou so much for this solution, it helps to resolved my issues.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.