Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Help with color coding text values in matrix

Hello,

 

I have a Matrix with 3 columns and all of these are text or categorical values like seen below. Significance and Log-Term Significance are both measures and I am interested in color coding their values or backgrounds. For example, Significant should be green and Non-Significant should be Red for both measures. But because these are not numerical values, I am having hard time color coding these.

kamsingh11_0-1624369141515.png

 

I was also trying to give 0 and 1 to these values, but for that the column names should not be measures. But these are measures, and therefore I was not able to do so.

Any help with example dax for color coding the results will appreciated!

 

Thanks!

 

1 ACCEPTED SOLUTION
DataZoe
Employee
Employee

@selimovd 's approach is correct but to do it with measures, you can change the syntax just a little like this:

 

Color Significance =
VAR vMaxSelected = [Significance]
RETURN
    SWITCH(
        vMaxSelected,
        "Non-Significant", "red",
        "Significant", "green"
    )

and then on the table, go to Conditional Formatting > Background > then by Field Value > using this measure.

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

View solution in original post

2 REPLIES 2
DataZoe
Employee
Employee

@selimovd 's approach is correct but to do it with measures, you can change the syntax just a little like this:

 

Color Significance =
VAR vMaxSelected = [Significance]
RETURN
    SWITCH(
        vMaxSelected,
        "Non-Significant", "red",
        "Significant", "green"
    )

and then on the table, go to Conditional Formatting > Background > then by Field Value > using this measure.

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

selimovd
Super User
Super User

Hey @Anonymous ,

 

you can do that with a measure and the conditional formatting:

Conditional table formatting in Power BI Desktop - Power BI | Microsoft Docs

 

For the measure something like this should do it:

Color Significance =
VAR vMaxSelected = MAX( myTable[Significance] )
RETURN
    SWITCH(
        vMaxSelected,
        "Non-Significant", "red",
        "Significant", "green"
    )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.