Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Absolute Value

Hi there

 

I'm pretty new to PowerBI where I am currently in trouble in regard to calculating the absolute value of data fields.

 

My visualization currently looks like:

Product.      Sales.      Forecast.      Dif.      AbsDif

Category1       90               117               -27           27

   SKU1.            1                 0                   1               1

   SKU2             2                0                    2               2

   SKU3            87              117                 -30          30

 

I have calculated/transformed the difference to absolute value, but I don't understand why the total AbsDif of the SKU's (category1) does not total 33?

 

Hope you can help.

8 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Pragati11 

     

    I think I have solved it by using the following formula:

     

    AbsBias = SUMX(VALUES('Table1'[SKU]),CALCULATE([AbsBias],ALL('Table1'[Category])))
  • Hi Anonymous ,

     

    Can you share your calculation for Absolute difference please?

     

    Thanks,

    Pragati

    • Anonymous's avatar
      Anonymous
      Not applicable

      Ofc 🙂 Pragati11 

       

      Bias = CALCULATE(SUM('Table1'[Sales])-SUM('Table2'[Forecast]))

       

      AbsBias = CALCULATE(ABS(SUM('Table1'[Sales])-SUM('Table2'[Forecast])))
      • Pragati11's avatar
        Pragati11
        Super User

        Hi Anonymous ,

         

        As you want your totals to be affected by your absolute value, you can write your measure something as below:

         

        AbsBias = CALCULATE(ABS(SUM('Table1'[Sales])-SUM('Table2'[Forecast]))) * (-1)

         

        Check if this helps.

         

        Thanks,

        Pragati