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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Color Coding Rows

Hi everyone!

 

I'm a little stuck on this issue and I'm not sure of a way around it.  I need to color code the rows in a matrix to show what IDs are relevant to each other.  For example IDs 10, 20 and 30 are all relevant to each other and need to be the same color while IDs 5, 15 and 25 are relevant to each other and need to be the same color but a different color from IDs 10, 20 and 30.  There are more than just these two but I just wanted to show an example.  Thanks for the help!

10RED
20RED
5BLUE
30RED
15BLUE
25BLUE
3 ACCEPTED SOLUTIONS
mahoneypat
Microsoft Employee
Microsoft Employee

You can make a simple measure like this (using your sample data table).  Any measure that returns a color in text format will work.

 

Text Color = MIN(Colors[Color])
 
And then use it to set up conditional formatting on the Font Color to get the result shown.
 
 
 

color1.png

 

color2.png

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

amitchandak
Super User
Super User

@Anonymous , Create a color measure like

color Measure =
Switch(True() ,
max(Table[ID]) in {10,20,30} ,"Red",
max(Table[ID]) in {5,15,25} ,"Blue",
"White"
)

 

And use that in conditional formatting using the "Field Value" option

 

Refer for Steps: https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

PhilipTreacy
Super User
Super User

Hi @Anonymous 

Please check this sample PBIX file

I assume you don't have a column with the color names in it, just a column of numbers?  In my example I've added a few extra numbers so you can see how it works.  You haven't specified what the relationship between ID's is so can'tprogram that in at this point so I'm assuming all numbers ending in 0 are related, all numbers ending in 5 are related - that's what is in your example.

You can create a measure to set the row color based on the value of the ID

 

RowColor = SWITCH(
    
    TRUE(),
    
    MOD(MIN('Table'[ID]),10) = 0, "red",

    MOD(MIN('Table'[ID]),10) = 3, "green",

    MOD(MIN('Table'[ID]),10) = 5, "blue",

    "black"

)

 

row-format.png

 

or the text color

 

TextColor = SWITCH(
    
    TRUE(),
    
    MOD(MIN('Table'[ID]),10) = 0, "red",

    MOD(MIN('Table'[ID]),10) = 3, "green",

    MOD(MIN('Table'[ID]),10) = 5, "blue",

    "black"

)

 

text-format.png 

 

In the Conditional Formatting for the ID set the Background or Font color, set it to Format By the Field Value (the measures) RowColor or TextColor.

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

5 REPLIES 5
PhilipTreacy
Super User
Super User

Hi @Anonymous 

Please check this sample PBIX file

I assume you don't have a column with the color names in it, just a column of numbers?  In my example I've added a few extra numbers so you can see how it works.  You haven't specified what the relationship between ID's is so can'tprogram that in at this point so I'm assuming all numbers ending in 0 are related, all numbers ending in 5 are related - that's what is in your example.

You can create a measure to set the row color based on the value of the ID

 

RowColor = SWITCH(
    
    TRUE(),
    
    MOD(MIN('Table'[ID]),10) = 0, "red",

    MOD(MIN('Table'[ID]),10) = 3, "green",

    MOD(MIN('Table'[ID]),10) = 5, "blue",

    "black"

)

 

row-format.png

 

or the text color

 

TextColor = SWITCH(
    
    TRUE(),
    
    MOD(MIN('Table'[ID]),10) = 0, "red",

    MOD(MIN('Table'[ID]),10) = 3, "green",

    MOD(MIN('Table'[ID]),10) = 5, "blue",

    "black"

)

 

text-format.png 

 

In the Conditional Formatting for the ID set the Background or Font color, set it to Format By the Field Value (the measures) RowColor or TextColor.

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


amitchandak
Super User
Super User

@Anonymous , Create a color measure like

color Measure =
Switch(True() ,
max(Table[ID]) in {10,20,30} ,"Red",
max(Table[ID]) in {5,15,25} ,"Blue",
"White"
)

 

And use that in conditional formatting using the "Field Value" option

 

Refer for Steps: https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-numbers-in-the-column
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak !

Your solution works perfectly for me but is there a way to have the rows show just the color and not show the words of that color? Thanks for the help!

 

ColorCode.png

Anonymous
Not applicable

@amitchandak ,

 

I figured it out, just needed to a bit more reading 😂, thanks again for the help!

mahoneypat
Microsoft Employee
Microsoft Employee

You can make a simple measure like this (using your sample data table).  Any measure that returns a color in text format will work.

 

Text Color = MIN(Colors[Color])
 
And then use it to set up conditional formatting on the Font Color to get the result shown.
 
 
 

color1.png

 

color2.png

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors