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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
andersonramos
Frequent Visitor

Cumulative sum by condition and by date

I need that when 'operation_external_id' = "602" appears on the timeline, that 'total_costs' accumulate considering 'calendar_date' and 'project_id'.


I need a sum conditioned on two variables:
1st when "602" appears in 'operation_external_id'
2nd when 1st accumulate 'total_costs' until date before '602' occurs

My data is as follows:
dim_operation_date: 'calendar_date'
dim_stand: 'projetc_id'
dim_operation: 'operation_external_id'
fact_followups: 'total_costs'

 

 I need this result when find 'operation_external_id' = "602",  give me the sum 259.65 + 3028 + 592.87 + 1660.42 + 5775.35 + 1233.12 + 975.53 + 281.02 + 1060.54 + 4226.68 + 328.57 =‬ 19421.75

 

image.png



6 REPLIES 6
Anonymous
Not applicable

@andersonramos 

Cumulative total =
CALCULATE (
    
SUM ( 'Table'[total_cost] ),
    
FILTER ( 'Table', [calendar_date] <= EARLIER ( 'Table'[calendar_date] ) )
)

Paul
Best
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

Please refer.

https://community.powerbi.com/t5/Desktop/Percentage-of-subtotal/td-p/95390

 

Also, you can try a quick measure. You have an option for category subtotal. Right-click on table or field you will get an option.

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Tks, but It didn't work, I need a sum conditioned on two variables:
1st when "602" appears in 'operation_external_id'
2nd when 1st accumulate 'total_costs' until date before '602' occurs

Anonymous
Not applicable

@andersonramos 

Can you show us how does it look like after using the formula? 
And It is appreciated if you can show your the your expected result in a table view, or just provide your pbix after removing sensitive infomation.

Best,
Paul

Anonymous
Not applicable

@andersonramos 

I also have the pbix if needed.

 

Cumulative total =
CALCULATE (
    SUM ( 'Table'[total_costs] ),
    FILTER (
        ALLEXCEPT ( 'Table', 'Table'[stand_id] ),
        [calendar_date] < EARLIER ( 'Table'[calendar_date] )
    )
)

 

cumulative total by id.JPG

https://qiuyunus-my.sharepoint.com/:u:/g/personal/paul_qiuyunus_onmicrosoft_com/EcKM6c0BZrpAvl52pjWj...
 

Paul

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors