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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
alsm
Helper III
Helper III

Running Total except for all buckets greater than current bucket

I have data that looks like

alsm_0-1698769879039.png

 

For a given date, I want to calcualte the sum where buckets are greater than equal to current bucket.

bucket = ON, 1M, 2M, .... and they are sorrted using column BucketDisplayOrder

RefDtAsDateBucketDisplayOrderBucketTotalRun Total Negated
30-Sep-231ON- 15,214,480,007          13,506,905,040
30-Sep-2321M   -    4,009,095,472             4,325,658,564
30-Sep-2332M-    2,340,791,557             2,340,701,152
30-Sep-2344M         316,698,698-               316,743,901
31-Aug-231ON- 12,025,581,264             3,925,291,987
31-Aug-2321M   -    2,573,944,777-               441,874,669
31-Aug-2332M-    2,068,740,731             2,068,650,386
31-Aug-2344M-    3,015,683,930             3,015,638,757
31-Jul-231ON- 15,045,532,484          12,139,824,710
31-Jul-2321M   -    2,830,709,505                818,728,299
31-Jul-2332M     1,118,164,354-           1,118,254,637
31-Jul-2344M-    2,011,845,783             2,011,800,641

 

I followed the suggestion here: Solved: Re: Running Total / cumulative by Group - Microsoft Fabric Community

 

VAR _fg = CALCULATE(-1*SUM(RT[TotalCashflow]),
                    ALLEXCEPT(RT,RT[RefDtAsDate]),
                    RT[BucketDisplayOrder] >= EARLIER(RT[BucketDisplayOrder])
                    )
return _fg

 

However, I get error:

 

Earlier refers to row context that does not exist

 

 

what am i missing?

1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

Hi, @alsm 

 

try below 

VAR _fg = CALCULATE(-1*SUM(RT[TotalCashflow]),
                    ALLEXCEPT(RT,RT[RefDtAsDate]),
                    RT[BucketDisplayOrder] >= max(RT[BucketDisplayOrder])
                    )
return _fg

 

and you can use  abs(SUM(RT[TotalCashflow]))  instead of -1*SUM(RT[TotalCashflow])

 

View solution in original post

2 REPLIES 2
alsm
Helper III
Helper III

Hi @Dangar332 

Thank you max works. 

for my understanding

ALLEXCEPT would filter all the dates selected in slicer/filter

After the ALLEXCEPT filter, it would filter all buckets greater than bucket selected in slicer/filter (and if there is no bucket selected then max bucket is default)

 

PS: cannot use abs() cause it can be positive/negative and it should be invereted. Though in sample data it was happening to be total of -ve number

 

Dangar332
Super User
Super User

Hi, @alsm 

 

try below 

VAR _fg = CALCULATE(-1*SUM(RT[TotalCashflow]),
                    ALLEXCEPT(RT,RT[RefDtAsDate]),
                    RT[BucketDisplayOrder] >= max(RT[BucketDisplayOrder])
                    )
return _fg

 

and you can use  abs(SUM(RT[TotalCashflow]))  instead of -1*SUM(RT[TotalCashflow])

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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