Forum Discussion
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 |
| Value 5 | 1 | 1 | 1 | 1 |
| Value 6 | 1 | 1 | 1 | 1 |
Each of the values in the above table is based on a calculated measure. My problem that I am facing is that I would liek to group values, in order to expand and minise rows based on grouping of the values. For example;
| Category A | Category B | Category C | Category D | ||
| Group 1 | |||||
| Value 1 | 1 | 1 | 1 | 1 | |
| Value 2 | 1 | 1 | 1 | 1 | |
| Group 2 | |||||
| Value 3 | 1 | 1 | 1 | 1 | |
| Value 4 | 1 | 1 | 1 | 1 | |
| Group 3 | |||||
| Value 5 | 1 | 1 | 1 | 1 | |
| Value 6 | 1 | 1 | 1 | 1 |
I appreciate that the matric has a +/- function in the formatting for rows, but given that my values are based off calculated measures, I don't have this functionality. A way around this would be perfect, so all help is much appreciated!
Thannks
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.
- Rows:
15 Replies
- MFelix
Super User
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.
- AnonymousNot applicable
Thanks for the quick reply. Is it possible to complete the first step given that the values are the results of calculated measures I have created?
Thanks
- MFelix
Super User
Hi Anonymous ,
The values that I have created in my file are several measures named Value 1, ..., Value 6. I assumed that what you mean by calculated measures right?
Can you please explain what you mean by complet the first step?
Regards,
MFelix
- AnonymousNot applicable
Hi, me again!
Firstly, thanks very much for your help with the solution to my problem. I have an additional step to this that I need some help with...
I have successfully created the groups within the table, and now would like to conditionally format some fo the values in the groups based on the results. The problem I have is that because I'm using just the one measure, based on the above, I can't conditionallly format any of the individual rows using the conditional formatting section of the format tab. I'm guessing I going to have to add some additional DAX to the existing grouping measure, or possibly amend the original measure that the grouping DAX references?
Any idea how I could get aroudn this.
Hope this makes sense.
- AnonymousNot applicable
Hello, thanks for the solution!
My measures are different types and want to format some of them as a whole number and some of them as a percentage. Is it possible? I tried to do it in your sample file but can't get the results.Thanks in advance!
- AnonymousNot applicable
I've found the solution, maybe someone else needs it. So in measures the function FORMAT(measure, "Percent") works fine. Any measure can have own format in this way.
- Rows:
- AnonymousNot applicable
Hi Anonymous ,
As far as i know, Matrix visual is the most common way to expand and collapse rows by groups but measure can only be add to Values field of matrix visual. So there are two ways I can think of.
The first way is using Calculated Column to get the values instead of Measure.
The second way is creating a Calculated Table based on the measure and table.
As i don't know the formula of your Measure, so i did a simple example about the second way.
Best Regards,
Jay
Community Support Team _ Jay Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.