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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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