Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Dax Aggregation for Country level

Hai All, I need one help on this  The above table % Share range is the expecting output I want  to achieve this logic at the Dax level Users want to see the % total at the country level For...
  • tamerj1's avatar
    4 years ago

    Hi Anonymous 

    Please use the following code

    % Share Range = 
    VAR Numerator = [# Model Number]
    VAR T1 =
        CALCULATETABLE ( Initiative, ALLEXCEPT ( Initiative, Initiative[Country] ) )
    VAR T2 = 
        SUMMARIZE ( T1, Initiative[Country], Initiative[Category] )
    VAR T3 =
        ADDCOLUMNS ( T2, "Models", [# Model Number] )
    VAR Denominator =
        SUMX ( T3, [Models] )
    RETURN
        IF ( HASONEVALUE ( Initiative[Country] ),
            DIVIDE ( Numerator, Denominator ),
            1
        )