Forum Discussion

Omega's avatar
Omega
Impactful Individual
9 years ago
Solved

Absolute at total

Dears,

 

I am currently trying to calculate the absolute difference between imports and exports at SKU level in the total. For the same SKU, I have imports and exports in every week. At the end of week 8, I'd like to check the absolute difference between Imports and Exports. How?

 

  • Anonymous's avatar
    Anonymous
    9 years ago

    Omega,

    Create the following measures and check if you get expected result.

    NewMeasure = IF(COUNTROWS(VALUES(Table2[SKU]))=1,Table2[ABSDIFF],SUMX(VALUES(Table2[SKU]),[ABSDIFF]))
    Measure 3 = [NewMeasure]/[ExportTotal]



    Regards,
    Lydia

24 Replies

  • dedelman_clng's avatar
    dedelman_clng
    Community Champion

    Can you share the code for your measure(s) ? PowerBI visuals don't total up columns and rows on measures - it calculates the measure based on the current filter context.

    • Omega's avatar
      Omega
      Impactful Individual

      Measure = SUMX(Table2,ABS(Table2[Export]-Table2[Import]))

      • dedelman_clng's avatar
        dedelman_clng
        Community Champion

        Your code is doing the absolute value, then summing.  You want to sum then do absolute value

         

        Measure = ABS(SUMX(Table2, (Table2[Export]-Table2[Import])))

  • vanessafvg's avatar
    vanessafvg
    Community Champion

    maybe im being daft but why dont you convert the number after you have done the calculation rather than creating absolute figures before you do the sum.  ie. * -1

    • Omega's avatar
      Omega
      Impactful Individual

      Can you please ellaborate further?

      • vanessafvg's avatar
        vanessafvg
        Community Champion

        SUMX(Table2,ABS(Table2[Export]-Table2[Import])) * -1

         

        (but like i say i could be being daft)

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Omega 

    How did you get the redmarked number, that´s the number I´m after but can´t seem to be able to produce.

    /Helena