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
Fiala
Helper II
Helper II

gradual countdown of values

Hello, can you help me please with measure?

I want the value from the "value -" column to be gradually subtracted from the value in the "value +" column from the oldest date if the value "value +" is> 0. I need to calculate this to calculate overtime for workers. Thank you for any advice and help.

Fiala_0-1626002675528.png

 

2 ACCEPTED SOLUTIONS
v-luwang-msft
Community Support
Community Support

Hi @Fiala ,

Try measure like below:

test1 =
VAR SUMALL =
    CALCULATE (
        SUM ( 'Table'[value +] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] <= MAX ( 'Table'[Date] )
                && 'Table'[Name] = MAX ( 'Table'[Name] )
        )
    )
VAR SUMLAST =
    CALCULATE (
        SUM ( 'Table'[value +] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] < MAX ( 'Table'[Date] )
                && 'Table'[Name] = MAX ( 'Table'[Name] )
        )
    )
VAR MINUSS =
    CALCULATE (
        SUM ( 'Table'[value -] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Name] = MAX ( 'Table'[Name] ) )
    )
RETURN
    IF (
        SUMLAST > MINUSS,
        MAX ( 'Table'[value +] ),
        IF ( SUMALL > MINUSS, SUMALL - MINUSS, 0 )
    )

Final get the below:

vluwangmsft_0-1626250888041.png

 

 

You could download my pbix flie if you need!

 

Wish it is helpuful for you!

 

Best Regards

Lucien

View solution in original post

v-luwang-msft
Community Support
Community Support

Hi  @Fiala ,

Change the max in dax to sum  when return ,see the below:

test2 = 
VAR SUMALL =
    CALCULATE (
        SUM ( 'Table'[value +] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[mon] <= MAX ( 'Table'[mon] )
                && 'Table'[meno] = MAX ( 'Table'[meno] )
        )
    )
VAR SUMLAST =
    CALCULATE (
        SUM ( 'Table'[value +] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[mon] < MAX ( 'Table'[mon] )
                && 'Table'[meno] = MAX ( 'Table'[meno] )
        )
    )
VAR MINUSS =
    CALCULATE (
        SUM ( 'Table'[value -] ),
        FILTER ( ALL ( 'Table' ), 'Table'[meno] = MAX ( 'Table'[meno] ) )
    )
RETURN
    IF (
        SUMLAST > MINUSS,
        sum ( 'Table'[value +] ),
        IF ( SUMALL > MINUSS, SUMALL - MINUSS, 0 )
    )

  

vluwangmsft_0-1626313155818.png

 

Best Regards

Lucien

View solution in original post

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi  @Fiala ,

Change the max in dax to sum  when return ,see the below:

test2 = 
VAR SUMALL =
    CALCULATE (
        SUM ( 'Table'[value +] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[mon] <= MAX ( 'Table'[mon] )
                && 'Table'[meno] = MAX ( 'Table'[meno] )
        )
    )
VAR SUMLAST =
    CALCULATE (
        SUM ( 'Table'[value +] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[mon] < MAX ( 'Table'[mon] )
                && 'Table'[meno] = MAX ( 'Table'[meno] )
        )
    )
VAR MINUSS =
    CALCULATE (
        SUM ( 'Table'[value -] ),
        FILTER ( ALL ( 'Table' ), 'Table'[meno] = MAX ( 'Table'[meno] ) )
    )
RETURN
    IF (
        SUMLAST > MINUSS,
        sum ( 'Table'[value +] ),
        IF ( SUMALL > MINUSS, SUMALL - MINUSS, 0 )
    )

  

vluwangmsft_0-1626313155818.png

 

Best Regards

Lucien

v-luwang-msft
Community Support
Community Support

Hi @Fiala ,

Try measure like below:

test1 =
VAR SUMALL =
    CALCULATE (
        SUM ( 'Table'[value +] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] <= MAX ( 'Table'[Date] )
                && 'Table'[Name] = MAX ( 'Table'[Name] )
        )
    )
VAR SUMLAST =
    CALCULATE (
        SUM ( 'Table'[value +] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Date] < MAX ( 'Table'[Date] )
                && 'Table'[Name] = MAX ( 'Table'[Name] )
        )
    )
VAR MINUSS =
    CALCULATE (
        SUM ( 'Table'[value -] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Name] = MAX ( 'Table'[Name] ) )
    )
RETURN
    IF (
        SUMLAST > MINUSS,
        MAX ( 'Table'[value +] ),
        IF ( SUMALL > MINUSS, SUMALL - MINUSS, 0 )
    )

Final get the below:

vluwangmsft_0-1626250888041.png

 

 

You could download my pbix flie if you need!

 

Wish it is helpuful for you!

 

Best Regards

Lucien

HI @v-luwang-msft , Thank you for your help. Your solution almost works great, but It doesn´t works if i need to see like this: 

Fiala_0-1626284041290.png

It should be 20 in February and March not 10 in this case :(...

 

Tab:

Fiala_1-1626284267671.png

 

ryan_mayu
Super User
Super User

@Fiala 

could you pls proivde the sample data?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

Top Solution Authors