Forum Discussion
Power BI - Matrix : Column Header Grouping for multiple measures
- 4 years ago
Hi, Anonymous ;
You should create a table like below:
Then create a measure.
Measure = SWITCH(MAX('Table2'[Measurename]),"FTE COUNT",CALCULATE([Measure 1]),"TEMP COUNT",[Measure 2],"BUDGET TMPS",[Measure 3],"FTE",[Measure 4],"FORE",[Measure 5])The final show:
Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for your response!
The article link that you've sent me suggests creating a 'hybrid' table for column groupings. In this case, the columns Sales and Target are grouped under 'Actuals' and the columns Budget and Forecast are grouped under 'BUD & FORC'. Are you suggesting that there may be other options to achieve the same results without a hybrid table?
In this example, the data is probably not the most suitable example, but I'd like to see the data that is missing from Matrix - 2 (outlined in the image below) as well as the totals for column groupings and the grand total for all columns.
Also, with this hybrid approach, since there is only one ‘Values for Matrix’ column in the values field of the Matrix, how do I apply different conditional formats to each column in the visual?
There is a label 'GROUPING' (which is a column name) on the top left corner on the Matrix that I'm not sure how to hide or remove it?
It all depends what you are trying to portray. The hybrid table can be useful, but if can also be detrimental to performance.
You can avchieve something similar to the structure you posted using the default table visual. For example:
To get total columns in a "hybrid" matrix structure, you need to build in the columns into the actual Hybrid table structure:
Values for Matrix =
VAR _Val =
SWITCH (
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ),
1, [Total Sales],
2, [Total Target],
3, [Total Sales] + [Total Target],
4, [Total Budget],
5, [Total Forecast],
6, [Total Budget] + [Total Forecast],
7,
[Total Sales] + [Total Target] + [Total Budget] + [Total Forecast]
)
RETURN
_Val
To add conditional formatting, create measure for colour codes and text:
Colour Code Full =
VAR _CC =
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 1, "#99d6ff",
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 2, "#4d79ff",
AND (
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 3,
[Total Sales] + [Total Target] > 1000
), "#339933",
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 3, "#b3e6b3",
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 4, "#ff66d9",
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 5, "#ff1a8c",
AND (
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 6,
[Total Budget] + [Total Forecast] > 1000
), "#ff0000",
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 6, "#ff9933",
AND (
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 7,
[Total Sales] + [Total Target] + [Total Budget] + [Total Forecast] > 2000
), "#8c1aff",
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 7, "#bf80ff"
)
RETURN
_CC
TEXT Code Full =
VAR _CC =
SWITCH (
TRUE (),
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 2, "White",
AND (
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 3,
[Total Sales] + [Total Target] > 1000
), "White",
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 5, "White",
AND (
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 6,
[Total Budget] + [Total Forecast] > 1000
), "White",
AND (
SELECTEDVALUE ( 'Hybrid Table'[INDEX] ) = 7,
[Total Sales] + [Total Target] + [Total Budget] + [Total Forecast] > 2000
), "White",
"Black"
)
RETURN
_CC
To get rid of the "GROUPING", simply rename the column blank (highlighted in above image).
I've attached the sample PBIX file
- oscarca2 years agoHelper I
How would you be able to sort the the rows by one of the column names in the group ? For example sort "Country" column on the rows based on descending order of "Total Actuals" which would put "UK" as the first row in the matrix ?
- oscarca2 years agoHelper I
PaulDBrown Any ideas ? or I assume since you haven't replied it might not be possible.
- ddpl2 years agoSolution Sage
PaulDBrownI have used the method you mentioned,
but the values are shown in same format, all two decimals number, but I want some of them as whole number, decimals and percentages.
How to achieve that?
- PaulDBrown2 years agoCommunity Champion
You need to use the FORMAT function to establish the format for each type of values.
You can see an example of this in this article:
- RahulNadkarni1 year agoFrequent Visitor
Great solution. Perfectly work for case my client want the measures to be grouped under some criteria. Only issue is that some columns are numeric in Millian and some are in %.
It there any way we can format these individual mesures.
- PaulDBrown1 year agoCommunity Champion
Sure. Just wrap the measures you need to format differently in the FORMAT function with the necessary format type
- RahulNadkarni1 year agoFrequent Visitor
Thanks.
I need to change color of a column based on below condition for a percentage field
1) if between -2 nd 2 then green
2) for rest cases red
But it's changing all values to Green inspite of check condition
The mesure is of type percentage.
Please let me know in case any solution.
TEXT Code for MainReport =
VAR _CC =
SWITCH (
TRUE (),
AND (
SELECTEDVALUE ( 'MainReport'[INDEX] ) = 15 ,
[UTILIZATION%] > 2
), "red",
AND (
SELECTEDVALUE ( 'MainReport'[INDEX] ) = 15 ,
AND([UTILIZATION%] <= 2 ,
[UTILIZATION%] >= -2)
), "green",
AND (
SELECTEDVALUE ( 'MainReport'[INDEX] ) = 15 ,
[UTILIZATION%] < -2
), "#ff0000"
)
RETURN
_CC