Forum Discussion

analyticspbi87's avatar
1 year ago
Solved

Need help on DAX calculation using distinct value from one column

Right now, I have data structured in a way where a value is repeated several times for each name.

 

However, for a calculation, I only need it the one time. My current calculation works when PowerBI is filtering for each name, but for consolidation purposes it is wrong.

 

NameGroupTypeYearValueEBITREVMultiplier
AnAApples                                                        1                                           1,005.001000020001.03
AnAApples                                                        2                                           2,378.63

10

000

20001.0609
AnAApples                                                        3                                              603.001000020001.092727
AnAApples                                                        4                                           1,237.261000020001.12550881
AbcAApples                                                        1                                              585.00300050001.03
AbcAApples                                                        2                                           1,219.86300050001.0609
AbcAApples                                                        3                                              516.25300050001.092727
AbcAApples                                                        4                                           1,122.66300050001.12550881

 

What I would like to show is the following set for the data each line when filtered,

EBIT % = Value (for the yr) / EBIT (per property) x Multiplier (for the year)

 1234
An10%25%7%14%
ABC20%43%19%42%

 

And when consolidated to show the following 

 1234
TOTAL13%29%9%20%

 

Right now, my measure is the following :

 

DIVIDE(
SUM('Table'[Value]), AVERAGE('Table'[EBIT])
*SUM('Table'[Multiplier])

 

However, the average for EBIT is wrong when I do the consolidated total.

 

Just wondering if there are way to go about it. TIA!

  • This definitely helped point me in the right direction.

     

    I ended up switching the formula to the following and it looks like it's working

     SUMX(DISTINCT('Table'[Name]), CALCULATE(MAX('Table'[EBIT])))
     
    Thank you so much!!!😊

2 Replies

  • freginier's avatar
    freginier
    Solution Sage

    Hey there!

     

    using AVERAGE which might not be the correct way to handle EBIT because it can be affected by row duplication. This leads to incorrect consolidated totals.

    try using this:

     

    EBIT % =
    DIVIDE(
    SUM('Table'[Value]),
    SUMX(DISTINCT('Table'[Year]), CALCULATE(SUM('Table'[EBIT])))
    ) * SUM('Table'[Multiplier])

     

    Hope this helps!

    😁😁

  • This definitely helped point me in the right direction.

     

    I ended up switching the formula to the following and it looks like it's working

     SUMX(DISTINCT('Table'[Name]), CALCULATE(MAX('Table'[EBIT])))
     
    Thank you so much!!!😊