Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

PowerBI Wrong Total Sum

Hi, PowerBI Community, I have a problem with this. I have measures like this: ppu_ac, ppu_ly. I use this in "Matrix" visual. For the calculation, I used this formula, simple division with DIVIDE: ...
  • Shahid12523's avatar
    1 year ago

     Problem: DIVIDE([AC Revenue], [Ac_hl]) works per row, but totals in Matrix aggregate first, then divide — causing wrong results.
     Fix: Use SUMX to force row-wise calculation even in totals:


    ppu_ac_fixed =
    SUMX(
    VALUES('Tabulka'[Dimenze]),
    DIVIDE([AC Revenue], [Ac_hl])
    )


    Optional: Wrap with HASONEVALUE if you want different logic for rows vs totals.

  • MohamedFowzan1's avatar
    1 year ago

    Hi Anonymous 

     

    For the total alone try using SUMX:

    ppu_ac_custom = 
    IF(
        HASONEVALUE('Tabulka'[Dimenze]),
        DIVIDE([AC Revenue], [Ac_hl]),               
        SUMX(
            VALUES('Tabulka'[Dimenze]),
            DIVIDE([AC Revenue], [Ac_hl])
        )                                          
    )