Constantin Marguier
Constantin Marguier

Reputation: 11

Wrong general total in a Power BI Matrix

I want to calculate the Herfindalh-Hirschmann Index (sum of market shares at square) bu publisher. In Power BI, i have 2 measures, the market share and the suare of market share for each publisher. My calculations are good but the general total is false for the square of market share.

My DAX code is this for the Market Share (correct calculation & total) : `Market Share = VAR Volume = SUM('Sales - Global'[Sales])

VAR AllVolume = CALCULATE(SUM('Sales - Global'[Sales]), ALL('Publisher'))

RETURN DIVIDE(Volume, AllVolume)`

My DAX code is this for the Squared Market Share. I ant to conserve the (*100) to better interprete the result. Calculations are good but the general total is incorrect. :

Market Share Square = 
VAR Volume = SUM('Sales - Global'[Sales])
VAR AllVolume = CALCULATE(SUM('Sales - Global'[Sales]), ALL('Publisher'[Publisher]))
VAR MarketShare = DIVIDE(Volume, AllVolume)*100
RETURN
    MarketShare * MarketShare

Table

Upvotes: 0

Views: 198

Answers (1)

David Browne - Microsoft
David Browne - Microsoft

Reputation: 89386

For the grand total the measure is evaluated without a single Publisher in the filter context. so

VAR Volume = SUM('Sales - Global'[Sales])

and

VAR AllVolume = CALCULATE(SUM('Sales - Global'[Sales]), ALL('Publisher'[Publisher]))

are the same.

If you want to run a calculation for each publisher and add them up use SUMX.

What you're expecting is a behavior called "visual calculations", which Power BI doesn't yet support. See https://learn.microsoft.com/en-us/power-platform/release-plan/2023wave2/power-bi/visual-calculations

Upvotes: 0

Related Questions