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
David-Menacho
Frequent Visitor

Cumulative Sum with condicion

Hi i want to implement the next measure, which is similar to a cumulative sum but with a Max conditional

 

DavidMenacho_0-1707338894045.png

 

The formula for the measure is:

- first value is 0

- for the rest: value is Max Between the prev measure plus actual value minus a constant (in this case 1) And 0

 

Adding an example in text format

 

DateValueMeasure
30/06/202110
01/07/202121
02/07/202155
03/07/2021610
06/07/2021413
07/07/2021214
08/07/2021518
09/07/2021118
10/07/2021421
11/07/2021222

 

¿Someone has a solution for this?

¡Thanks for your help!

 

Regards

 

1 ACCEPTED SOLUTION
Daniel29195
Super User
Super User

@David-Menacho 

output : 

Daniel29195_0-1707339488326.png

use the meaure below : 

this measure assume that you are reading the date from the same table , 

if not,  then simply change allselected(tbl_name[date])  to allselected(dimdate[date]) and orderby(dimdate[date], asc)

Measure 10 = 
var prev_value = 
CALCULATE(
    SUM('tbl_name'[Value]),
    OFFSET(
        -1,
        ALLSELECTED('tbl_name'[date]),
        ORDERBY('tbl_name'[date] , asc)
    )
)

return 
MAX(0,SUM('tbl_name'[Value]) - 1 + prev_value)

 

 

let me know if it works for you .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

View solution in original post

4 REPLIES 4
Daniel29195
Super User
Super User

@David-Menacho 

output : 

Daniel29195_0-1707339488326.png

use the meaure below : 

this measure assume that you are reading the date from the same table , 

if not,  then simply change allselected(tbl_name[date])  to allselected(dimdate[date]) and orderby(dimdate[date], asc)

Measure 10 = 
var prev_value = 
CALCULATE(
    SUM('tbl_name'[Value]),
    OFFSET(
        -1,
        ALLSELECTED('tbl_name'[date]),
        ORDERBY('tbl_name'[date] , asc)
    )
)

return 
MAX(0,SUM('tbl_name'[Value]) - 1 + prev_value)

 

 

let me know if it works for you .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

 

thanks! it was what i needed

vanessafvg
Super User
Super User

so are you saying you want the max value please provide an example of what right looks like and supply the data in text format.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




thanks for your time, i edited my question

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
Top Kudoed Authors