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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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