Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Grouping calculated measures as values in a matrix

Hi,   I current have a table as follows;     Category A Category B Category C Category D Value 1 1 1 1 1 Value 2 1 1 1 1 Value 3 1 1 1 1 Value 4 1 1 1 1 Valu...
  • MFelix's avatar
    6 years ago

    Hi Anonymous ,

     

    Create a table with the following format:

    Measure    Group

    Value 1 Group 1
    Value 2 Group 1
    Value 3 Group 2
    Value 4 Group 2
    Value 5 Group 3
    Value 6 Group 3

     

    Now add the following measure:

    Grouping Calculation = 
    VAR Group_calculation =
        SWITCH (
            SELECTEDVALUE ( 'Grouping_Measures'[Group] );
            "Group 1"; [Value 1] + [Value 2];
            "Group 2"; [Value 3] + [Value 4];
            "Group 3"; [Value 5] + [Value 6]
        )
    RETURN
        SWITCH (
            SELECTEDVALUE ( 'Grouping_Measures'[Measure] );
            "Value 1"; [Value 1];
            "Value 2"; [Value 2];
            "Value 3"; [Value 3];
            "Value 4"; [Value 4];
            "Value 5"; [Value 5];
            "Value 6"; [Value 6];
            Group_calculation
        )
    

     

    Format your matrix with the following way:

    • Rows:
      • Grouping_Measures[Group]
      • Grouping_Measures[Measure]
    • Columns
      • Table[Category]
    • Values
      • [Groupin Calculation]

     

    See attach result.