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

View all the Fabric Data Days sessions on demand. View schedule

Reply
MrPontes
Regular Visitor

How to set the graph colors based on the category?

MrPontes_0-1607019097648.png

In the graph above, each element of the Y-axis belongs to a category (sometimes several elements belong to the same category).

I would like to set the bar colors in a way that we see what group of elements belong to the same category. 

For example: if 3 elements belong to the same category, their bars are going to be the same color.

How do I do that?

And if I can't do that, is there another kind of graph that allows me to do that?

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @MrPontes 

Please see attached PBIX file for solution.

I'm using this subset of your data and have added a column to represent the category that determines the bar color.

color-bars-data.png

You need to create a measure like this

 

Category Color = SWITCH(
    
    TRUE(),
    
    MIN('Table'[Category]) = "A", "red",

    MIN('Table'[Category]) = "B", "green",

    MIN('Table'[Category]) = "C", "blue",

    "black"

)

 

 

Then with Name on the Axis and Value in Values, click on Format -> data colors and then on the fx icon to create a formatting rule

fx-button.png

 

Format by : Field value and Based on Field : Category Color (the new measure we just created)

formatting-rule.png

 

To give this

colored-bars.png

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

1 REPLY 1
PhilipTreacy
Super User
Super User

Hi @MrPontes 

Please see attached PBIX file for solution.

I'm using this subset of your data and have added a column to represent the category that determines the bar color.

color-bars-data.png

You need to create a measure like this

 

Category Color = SWITCH(
    
    TRUE(),
    
    MIN('Table'[Category]) = "A", "red",

    MIN('Table'[Category]) = "B", "green",

    MIN('Table'[Category]) = "C", "blue",

    "black"

)

 

 

Then with Name on the Axis and Value in Values, click on Format -> data colors and then on the fx icon to create a formatting rule

fx-button.png

 

Format by : Field value and Based on Field : Category Color (the new measure we just created)

formatting-rule.png

 

To give this

colored-bars.png

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!


Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors