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! Learn more

Reply
djbuncle
Helper I
Helper I

MIN calculation on cumulative value using FILTER

Hi, I was wondering whether someone can help me with the behaviour of this calculation.

I'm trying to get the number of days (DaySeq) it takes for the cumulative value (CumulativeProfit) to reach 0 where it starts from a negative value. The model I have here is...

 

RD Model.png

 

CumulativeProfit := CALCULATE([Profit], FILTER(ALL('Days Since FTD'), 'Days Since FTD'[DaySeq] <= MAX('Days Since FTD'[DaySeq])))

 

RD Pivot.png

 

In the pivot data here we see that player 1 reached profit of >=0 after 2 days and player 2 in 7 days (in yellow and green respectively). However my [Repayment Days] calculation returns 1 for both players. Here's the formula I'm using:

 

Repayment Days:= CALCULATE(MIN('Days Since FTD'[DaySeq]), FILTER('PlayerRev',[CumulativeProfit] >= 0))

 

I have a hunch that the cumulative value on which this is based is putting a spanner in the works. Any suggestions would be much appreciated.

Cheers.

1 ACCEPTED SOLUTION

@djbuncle

Here are a few ways of writing the measure that I can think of:

 

Repayment Days 1 :=
CALCULATE (
    MIN ( 'Days Since FTD'[DaySeq] ),
    FILTER ( 'Days Since FTD', [Cumulative Profit] >= 0 )
)
Repayment Days 2 :=
FIRSTNONBLANK ( 'Days Since FTD'[DaySeq], IF ( [Cumulative Profit] >= 0, 1 ) )
Repayment Days 3 :=
MINX (
    'Days Since FTD',
    IF ( [Cumulative Profit] >= 0, 'Days Since FTD'[DaySeq] )
)

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

4 REPLIES 4
v-yuta-msft
Community Support
Community Support

Hi djbuncle,

 

Modify your first measure as below and check if it can work:

 

CumulativeProfit =
CALCULATE (
    SUM ( [Profit] ),
    FILTER (
        ALL ( 'Days Since FTD' ),
        'Days Since FTD'[DaySeq] <= MAX ( 'Days Since FTD'[DaySeq] )
    )
)

Regards,

Jimmy Tao

Thanks Jimmy, but the [Profit] measure I have in the cumulative calculation is already a SUM([ProfitMeasure]) so that won't be the issue, I tried it and it made no difference 😞

@djbuncle

Here are a few ways of writing the measure that I can think of:

 

Repayment Days 1 :=
CALCULATE (
    MIN ( 'Days Since FTD'[DaySeq] ),
    FILTER ( 'Days Since FTD', [Cumulative Profit] >= 0 )
)
Repayment Days 2 :=
FIRSTNONBLANK ( 'Days Since FTD'[DaySeq], IF ( [Cumulative Profit] >= 0, 1 ) )
Repayment Days 3 :=
MINX (
    'Days Since FTD',
    IF ( [Cumulative Profit] >= 0, 'Days Since FTD'[DaySeq] )
)

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Absolute champion, @OwenAuger. All 3 of those worked.

Much appreciated.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Users online (3,741)