cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
badger123 Member
Member

Re: Max of Summed Values of a Category

Hi @AlB

 

I don't want to use a slicer for category, I'm looking to do the same as before where an item is selected and the weighted average should be calculated based on the corresponding category. I'm guessing I will need to take a similar approach combining this... 

 

VAR _ItemCategory =
    SELECTEDVALUE ( Table2[Category] )

 

and this... 

 

WeightedAverageGrowthCat =
DIVIDE (
    SUMX ( Table3; Table3[Growth] * Table3[volume] );
    SUM ( Table3[volume] )
)

but don't quite know what that measure would be?!  

Highlighted
Super User
Super User

Re: Max of Summed Values of a Category

@badger123

Yeah you could follow the same logic, or change it a bit:

Table2 is as previously, Table3 the new one that you show with the growth.

 

WeightedAverageGrowthCat_V2 =
VAR _ItemCategory =
    SELECTEDVALUE ( Table2[Category] )
RETURN
    CALCULATE (
        DIVIDE (
            SUMX (
                Table3;
                Table3[Growth] * Table3[volume]
            );
            SUM ( Table3[volume] )
        );
        CALCULATETABLE (
            VALUES ( Table2[ID] );
            Table2[Category] = _ItemCategory;
            ALL ( Table2 )
        )
    )

 

Code formatted with   www.daxformatter.com

badger123 Member
Member

Re: Max of Summed Values of a Category

@AlB Awesome! Thank you so much! Smiley Happy