Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Subtracting Total Value

Hi Team,

 

DAX function for subtract total value -limt and remaining value reflect all size rows like z1 (26.9-9.8 and remaining value 17.1) see output table

 

 

Below table is output file (after subtrating data for total size -Limit )

Remaining Val is (ex. z1 is 26.9 subtract with limit (z1 - 9.8) and remaining value reflect all z1 rows)

 

 

 

 

 

Thanks,

KV's

  • Anonymous , Try a new column like

    sumx(filter(table, [size] = earlier([size]) ),[Qas(m)]) - maxx(filter(table, [size] = earlier([size]) ),[Limit])

     

    or a measure like

    sumx(filter(allselected(table), [size] = max([size]) ),[Qas(m)]) - maxx(filter(allselected(table), [size] = max([size]) ),[Limit])

2 Replies

  • Anonymous , Try a new column like

    sumx(filter(table, [size] = earlier([size]) ),[Qas(m)]) - maxx(filter(table, [size] = earlier([size]) ),[Limit])

     

    or a measure like

    sumx(filter(allselected(table), [size] = max([size]) ),[Qas(m)]) - maxx(filter(allselected(table), [size] = max([size]) ),[Limit])

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

    There are two ways:

    Here are the steps you can follow:

    The first method:

    1. Create measure.

    Remaining Val =
    var _1=CALCULATE(SUM('Table'[Qas]),FILTER(ALL('Table'),'Table'[size]=MAX('Table'[size])))
    var _2=CALCULATE(MAX('Table'[Limit]),FILTER(ALL('Table'),'Table'[size]=MAX('Table'[size])))
    return _1 -_2

    2. Result.

    The second method:

    1. Create Calculated table.

    table1 =
    SUMMARIZE('Table','Table'[size],
    'Table'[Desc],
    "Limit",CALCULATE(MAX('Table'[Limit])),
    "Remaining Val",CALCULATE(SUM('Table'[Qas]),FILTER(ALL('Table'),'Table'[size]=MAX('Table'[size])))-CALCULATE(MAX('Table'[Limit]),FILTER(ALL('Table'),'Table'[size]=MAX('Table'[size]))))

    2. Result.

    You can downloaded PBIX file from here.

     

    Best Regards,

    Liu Yang

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