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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
srinivas_fabric
Regular Visitor

Adding different Colours for different Row headers in Matrix in Power BI.

I have a matrix visual in Power BI with rows and Columns . I want to add different colours for different row headers. How to do it ?

1 ACCEPTED SOLUTION

Hi @srinivas_fabric,
Thanks for reaching out to the Microsoft fabric community forum. 

I recreated the sample data using the screenshot you provided.

Unpivot the Data
In Power Query, select the columns 2022, 2023, and 2024, right-click and choose "Unpivot Columns," then rename the resulting columns to Product, Year, and Sales.

Create a Row Color Measure
Measure:
RowColor =

SWITCH(

    SELECTEDVALUE('Sales'[Product]),

    "Smartphones", "#FFCCCC",        // Light Red

    "Laptops", "#CCE5FF",            // Light Blue

    "Tablets", "#D5F5E3",            // Light Green

    "Headphones", "#FFF2CC",         // Light Yellow

    "Smartwatches", "#E6CCFF",       // Light Purple

    "#FFFFFF"                        // Default White

)

Build the matrix by placing Product in Rows, Year in Columns, and adding both Sales and Product to Values (the second Product is for coloring). Then, apply conditional formatting by clicking the dropdown on the second Product field, choosing Conditional formatting > Background color, and setting it to format by field value using the RowColor measure.

Please go through the screenshot and pbix file for detailed information.
vmenakakota_0-1747633004790.png

If I misunderstand your needs or you still have problems on it, please feel free to let us know.   

Best Regards, 
Menaka.
Community Support Team  

 

 

View solution in original post

9 REPLIES 9
Samarth_18
Community Champion
Community Champion

@srinivas_fabric  If you are limited in creating a new table, you can create a measure as shown below and use it for conditional formatting.

 

RowColor =
SWITCH(
[RowCategory],
"Category A", "#FF0000", // Red
"Category B", "#00FF00", // Green
"Category C", "#0000FF", // Blue
"#000000" // Default Black
)


You can explore custom visuals from the marketplace like:

  • TableSorter or Matrix by MAQ Software
  • Acterys Matrix Light

Some of these visuals offer more flexible formatting, including row header styling.

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Thank you for your Solution .Please let me explain by applying on this Sample file.

srinivas_fabric_0-1747483913434.png

 

Hi @srinivas_fabric ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster. 

Best Regards, 
Menaka.
Community Support Team 

Hi  @srinivas_fabric ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.

Best Regards, 
Menaka.
Community Support Team  

Hi @srinivas_fabric  ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster. 

Best Regards, 
Menaka.
Community Support Team  

Hi @srinivas_fabric,
Thanks for reaching out to the Microsoft fabric community forum. 

I recreated the sample data using the screenshot you provided.

Unpivot the Data
In Power Query, select the columns 2022, 2023, and 2024, right-click and choose "Unpivot Columns," then rename the resulting columns to Product, Year, and Sales.

Create a Row Color Measure
Measure:
RowColor =

SWITCH(

    SELECTEDVALUE('Sales'[Product]),

    "Smartphones", "#FFCCCC",        // Light Red

    "Laptops", "#CCE5FF",            // Light Blue

    "Tablets", "#D5F5E3",            // Light Green

    "Headphones", "#FFF2CC",         // Light Yellow

    "Smartwatches", "#E6CCFF",       // Light Purple

    "#FFFFFF"                        // Default White

)

Build the matrix by placing Product in Rows, Year in Columns, and adding both Sales and Product to Values (the second Product is for coloring). Then, apply conditional formatting by clicking the dropdown on the second Product field, choosing Conditional formatting > Background color, and setting it to format by field value using the RowColor measure.

Please go through the screenshot and pbix file for detailed information.
vmenakakota_0-1747633004790.png

If I misunderstand your needs or you still have problems on it, please feel free to let us know.   

Best Regards, 
Menaka.
Community Support Team  

 

 

Thanks for your Answer.Please let me explain by applying on this Sample data.

srinivas_fabric_0-1747483350545.png

 

DataNinja777
Super User
Super User

Hi @srinivas_fabric ,

 

To add different colors for different row headers in a Power BI matrix, you can create a separate color mapping table and use that for conditional formatting. For example, create a table named ProductColors with the following structure:

 

Product         Color Code
Product A       #FFCCCC
Product B       #CCE5FF
Product C       #D5F5E3

In your main data model, if you have a table with a Product column, you can either relate it to ProductColors or just use a lookup in your DAX. Create a measure to retrieve the color for each product like this:

RowHeaderColor = 
LOOKUPVALUE(
    ProductColors[Color Code],
    ProductColors[Product],
    SELECTEDVALUE(YourMainTable[Product])
)

Then, in the matrix visual, instead of placing Product in the Rows section, place it in Values so you can apply conditional formatting. Use the RowHeaderColor measure for background color formatting by choosing "Format by field value" and selecting the measure. Power BI doesn't support directly coloring row headers, so this method fakes the header look by treating the label as a value and styling it accordingly.

 

Best regards,

Thank you for your Solution. Please let me explain by appling on this sample file.

srinivas_fabric_0-1747484008308.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.