Forum Discussion

AllanBerces's avatar
AllanBerces
Post Prodigy
6 months ago
Solved

If Negative Sum 0

Hi good day, can anyone help me on my calculated column, from my table we required if the sum of total progress per Job is negative then the result is 0 if not then Progress.

DESIRED OUTPUT

JobTradeYearProgressWeek No.Result
KI222221Mech20269.1939.19
KI222221Mech20261.8141.81
KI222221Mech202615.68215.68
KI222221Mech202614.6114.6
WERT0123E&I20264.3414.34
WERT0123E&I20265.5225.52
WERT0123E&I20263.433.4
WERT0123E&I202669.27469.27
QWERT65Civil202630.97130.97
QWERT65Civil20266.5126.51
QWERT65Civil202614.56314.56
QWERT65Civil202617.7417.7
BFGT435Mech20269.4440
BFGT435Mech2026-30.0620
TYJJ56984Plumber20260.0210
TYJJ56984Plumber2026-9.4720
TYJJ56984Plumber2026-0.0230
TYJJ56984Plumber20264.4840
HOYTJ0978Civil2026-4.0620
HOYTJ0978Civil202619.7340
HOYTJ0978Civil2026-39.9930
  • Hii AllanBerces 

     

    If the total Progress per Job (and Year) is negative, return 0, otherwise return the original Progress value.

    Result = 
    VAR TotalJobProgress =
        CALCULATE (
            SUM ( 'ProgressData'[Progress] ),
            ALLEXCEPT ( 'ProgressData', 'ProgressData'[Job], 'ProgressData'[Year] )
        )
    RETURN
    IF ( TotalJobProgress < 0, 0, 'ProgressData'[Progress] )
    

     

     

  • Result = 
    IF(
        CALCULATE(
            ISEMPTY( DATA ), ALLEXCEPT( DATA, DATA[Job] ), DATA[Progress] < 0
        ),
        DATA[Progress],
        0
    )

  • Please try the formula below:

    Result =
    VAR JobTotalProgress =
        CALCULATE (
            SUM ( 'Table'[Progress] ),
            ALLEXCEPT ( 'Table', 'Table'[Job] )
        )
    RETURN
    IF (
        JobTotalProgress < 0,
        0,
        'Table'[Progress]
    )
  • Hi AllanBerces 

     

    You can use MAX to make sure that it returns either the positive result or zero at the minimum.

    Progress Per Job =
    MAX (
        CALCULATE ( SUM ( 'Table'[Progress] ), ALLEXCEPT ( 'Table', 'Table'[Job] ) ),
        0
    )
    

     

  • Hi,

    This calculated column formula works

    =if(CALCULATE(SUM(Data[Progress]),FILTER(Data,Data[Job]=EARLIER(Data[Job])))<0,0,Data[Progress])

    Hope this helps.

     

6 Replies

  • Hi AllanBerces 

     

    You can use MAX to make sure that it returns either the positive result or zero at the minimum.

    Progress Per Job =
    MAX (
        CALCULATE ( SUM ( 'Table'[Progress] ), ALLEXCEPT ( 'Table', 'Table'[Job] ) ),
        0
    )
    

     

  • Hii AllanBerces 

     

    If the total Progress per Job (and Year) is negative, return 0, otherwise return the original Progress value.

    Result = 
    VAR TotalJobProgress =
        CALCULATE (
            SUM ( 'ProgressData'[Progress] ),
            ALLEXCEPT ( 'ProgressData', 'ProgressData'[Job], 'ProgressData'[Year] )
        )
    RETURN
    IF ( TotalJobProgress < 0, 0, 'ProgressData'[Progress] )
    

     

     

  • Result = 
    IF(
        CALCULATE(
            ISEMPTY( DATA ), ALLEXCEPT( DATA, DATA[Job] ), DATA[Progress] < 0
        ),
        DATA[Progress],
        0
    )

  • Please try the formula below:

    Result =
    VAR JobTotalProgress =
        CALCULATE (
            SUM ( 'Table'[Progress] ),
            ALLEXCEPT ( 'Table', 'Table'[Job] )
        )
    RETURN
    IF (
        JobTotalProgress < 0,
        0,
        'Table'[Progress]
    )
  • Hi,

    This calculated column formula works

    =if(CALCULATE(SUM(Data[Progress]),FILTER(Data,Data[Job]=EARLIER(Data[Job])))<0,0,Data[Progress])

    Hope this helps.