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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
preacher_baby
Frequent Visitor

DAX measure for the column/pie/ charts to color only the max value bar/slice

Basically title. Say I have a bar / column chart with the maximum count of category having 5, while others have lower. I want this particular bar to be color with specific color, while other bars should have the same color.

2 REPLIES 2
Anonymous
Not applicable

Hi @preacher_baby ,

 

Has your problem been solved? If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out. Thanks in advance.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

ChiragGarg2512
Super User
Super User

@preacher_baby , need to create a DAX measure using switch statement. In switch statement first parameter is values(column with category name), and the expression will be a dax that gives the name of category with highest count, value if this condition is true is the color wanted for top category and next is the color wated for remaining categories.

The expression will be made using index function.

Color top 1 = SWITCH(values('TableName'[category]),
maxx(INDEX(1,ALLSELECTED('TableName'[category]),ORDERBY([category count],DESC)), [category]), "Green",
"blue")

Change color as per convenience. Category count is a measure that with dax count('TableName'[category]).
If the category column is sorted by any numerical value include that column in ALLSELECTED.
 
Thank You.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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