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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
cleslie
New Member

Dynamically set legend colors based on number of items selected

I have a clustered bar chart displaying Average Dialy Visits (counts) by month (count on y axis, month on x axis) collected at a number of different locations. I have a slicer allowing the end use to select 1 or more locations (there are 45 locations in total). In order to facilitate comparaison of monthly visitation counts for different locations, I am using the locations as the categories for the "Legend" field.

 

Typically, the end use will only select a few locations at a time (let's say a max of 3). However, by default Power BI assigns a static color to each category. What I would like to do is assign the legend colors dynamically based on the number of locations selected. For example, if only one location is selected it is always green. If two are selected, one is green and one is blue. If a third is selected, green, blue and yellow. Etc.

 

It really doesn't matter which location is assigned which color when selected so that isn't a constraint.

 

2 REPLIES 2
cleslie
New Member

I have a clustered bar chart displaying Average Dialy Visits (counts) by month (count on y axis, month on x axis) collected at a number of different locations. I have a slicer allowing the end use to select 1 or more locations (there are 45 locations in total). In order to facilitate comparaison of monthly visitation counts for different locations, I am using the locations as the categories for the "Legend" field.

 

Typically, the end use will only select a few locations at a time (let's say a max of 3). However, by default Power BI assigns a static color to each category. What I would like to do is assign the legend colors dynamically based on the number of locations selected. For example, if only one location is selected it is always green. If two are selected, one is green and one is blue. If a third is selected, green, blue and yellow. Etc.

 

It really doesn't matter which location is assigned which color when selected so that isn't a constraint.

 

Hi @cleslie,

 

Nope, current power bi not support this.

 

In fact, condition formatting feature support to use other column value to setting color, but you can't create dynamic calculate column/table based on slicer/filter to make color fields dynamic.

 

BTW, you can create dynamic measure based on slicer/filter, but it can't use on legend and axis fields.

 

Regards,

Xiaoxin Sheng

 

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors