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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Diksha_2
Frequent Visitor

How to ensure Power BI choose color based on the number of categories not value

I have created a stack column chart which has 15 categories. I have a slicer with all categories value. I know user will select around 1-4 categroies at a time to view data. So, I want Power BI to choose color based on the Palette. So if user has selected 1 category then it should show in in 1st color, if 2 categories are selected then it should show 1st 2 colors and so on. However, by default Power BI has assigned colors to categories and have been showing them but I want it to always follow the Palette sequence.

 

8 REPLIES 8
v-lgarikapat
Community Support
Community Support

Hi @Diksha_2 ,

Thanks for reaching out to the Microsoft fabric community forum.

@Shahid12523 , @danextian  

Thanks for your prompt response

@Diksha_2 ,

I wanted to follow up and confirm whether you’ve had the opportunity to review the information provided by @Shahid12523 , @danextian  If you have any questions or need further clarification, please don’t hesitate to reach out.

 

We appreciate your engagement and thank you for being an active part of the community.

Best regards,
Lakshmi.

I am grateful for the replies and they might be useful in some situation but I think my problem will not solve until Power BI introduce the funcationality as I need it as default for all my reports.

 

Hi @Diksha_2 ,

Thanks for the responses.

 

I recommend submitting this scenario as a feature request on the official Fabric Ideas forum. The Product Team actively reviews submissions there, and suggestions with strong community support are often considered for future enhancements.

https://ideas.fabric.microsoft.com/

 

We appreciate your engagement and thank you for being an active part of the community.

Best regards,
Lakshmi.

Hi @Diksha_2 ,

 

I just wanted to follow up with you to check if you had a chance to submit the scenario to the Ideas forum.

 

Best Regards,

Lakshmi

Diksha_2
Frequent Visitor

Many thanks Shahid and danextian. However, I am using them as legend not categories. My x-axis is generally date.
I hope Power BI introduce this feature soon. Otherwise, I do not see the relevence of palette at least in my reports. This is because user can never just copy the charts or visualise them easily. They have to download the data and create their own visual which defeats the purpose of dashboard.

Yes, you’re right with legend, Power BI fixes colors to category names, so palette sequencing doesn’t work.

 

Options now:

Use a color measure + rank workaround.

Use a Deneb (Vega-Lite) visual for full palette control

Shahed Shaikh
Shahid12523
Community Champion
Community Champion

Power BI always fixes colors to category names.


To force colors to follow the palette sequence based on selection:

Create a rank measure with RANKX over selected categories.

Create a color measure using SWITCH to map rank → palette color.

Apply that measure in Data colors → fx → Field value.

 

This way, 1st selected category = 1st color, 2nd = 2nd color, etc.

Shahed Shaikh
danextian
Super User
Super User

Hi @Diksha_2 

 

If those categories are being used as X-axis categories, you can create a measure to be used in conditional formatting. For example: 

Category Color in the current context = 
VAR _rank =
    RANKX (
        ALLSELECTED ( Category ),
        CALCULATE ( MAX ( Category[sort] ) ),
        ,
        ASC,
        DENSE
    )
VAR _color =
    MAXX ( FILTER ( Colors, Colors[Rank] = _rank ), [Color] )
RETURN
    _color

The rank is the above measure is determined based on value of Category[sort] for all visible category rows but a different value can be used (sales, volume or the category itself). The Colors table contains all colors for each rank. 

danextian_0-1755863619684.png

danextian_1-1755863637509.gif

 

Note: Power BI does not remember the order in which the categories were selected. This approach is possible only if the column is being used as a category and not a legend - legends do not currently support conditional formatting.

 

Please see the attached pbix.

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.