Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

SUM the ABS total

Hi all,

I have a table with ID, Income and Outcome columns (both calculated measures), Difference (which is a calc.metric =ABS(Income-Outcome). 

 

 




I'd like to show the Total Difference value and I need the actual sum ot the diff values (1754), but currently with my formula Difference = ABS(Income-Outcome) the total result in PBI is 1552.

Any ideas for a working measure?

Thank you.


  • hi  Anonymous 

    This is a measure total problem, for your case, just add a new measure as below:

    Measure = 
    VAR _table = SUMMARIZE('Table1',[ID],"_value",[Difference])
    RETURN
    SUMX(_table,[_value])

     

    Regards,

    Lin

8 Replies

  • v-lili6-msft's avatar
    v-lili6-msft
    Icon for Community Support rankCommunity Support

    hi  Anonymous 

    This is a measure total problem, for your case, just add a new measure as below:

    Measure = 
    VAR _table = SUMMARIZE('Table1',[ID],"_value",[Difference])
    RETURN
    SUMX(_table,[_value])

     

    Regards,

    Lin

    • Anonymous's avatar
      Anonymous
      Not applicable



      I tried this but my ID column come from a different table and I cannot use the suggested formula. Any ideas? And could you specify which value should I use in the "Value" part?

      Also, the measures are calculate fields, not columns, and some functions don't work.

      Thank you.

      • v-lili6-msft's avatar
        v-lili6-msft
        Icon for Community Support rankCommunity Support

        hi  Anonymous 

        could you please share your sample pbix file for us have atest, that will be a great help.

         

        Regards,

        Lin

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous  what is the measure which  you used for sum of income and outcome...I tried replicating your issue but worked fine

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi @HusnaBanu413,

      For the Income I used CALCULATE (SUM ( 'Table1'[Income]; For the Outcome is CALCULATE (SUM ( 'Table1'[Outcome]

      The first formula, which I used Is Difference = ABS(Income-Outcome) > didn't work.
      I tried with Difference_2 = 
      SUMX(VALUES('Table 2'[ID]),IF('Table1'[Income]-Table1'[Outcome]<0, ABS('Table1'[Income]-Table1'[Outcome],ABS('Table1'[Income]-Table1'[Outcome]))  > work only in some cases, where the Outcome is not 0.

      Thank you.