cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kavya123 Frequent Visitor
Frequent Visitor

Change Colors in Bar Chart by selecting color button

Hi Everyone,

 

I have a requirenment to edit the colors in Bar Chart. In the below attached screenshot for example if we click on red color button then all the bar charts should display red color bars.  Similarly if we select green button then the bars should change to green color.

 

Thanks in advance.

 

colors.png

1 ACCEPTED SOLUTION

Accepted Solutions
sturlaws Regular Visitor
Regular Visitor

Re: Change Colors in Bar Chart by selecting color button

Hi,

 

Not functionality that exists out of the box, but there are a couple of workarounds that might give you something similar

 

You could try bookmarks and buttons, in power bi desktop use ctrl-click to use buttons

Or you could use a dummy table to create a measure which control the colors of a chart

 

both methods are shown in this file:

example filbookmarks.PNGmeasure.PNG

5 REPLIES 5
sturlaws Regular Visitor
Regular Visitor

Re: Change Colors in Bar Chart by selecting color button

Hi,

 

Not functionality that exists out of the box, but there are a couple of workarounds that might give you something similar

 

You could try bookmarks and buttons, in power bi desktop use ctrl-click to use buttons

Or you could use a dummy table to create a measure which control the colors of a chart

 

both methods are shown in this file:

example filbookmarks.PNGmeasure.PNG

ryan_mayu Established Member
Established Member

Re: Change Colors in Bar Chart by selecting color button

@sturlaws

 

I am also interested in your solutions. However, I can't access to your file because I am in China. I know how to do that by using bookmarks.

 

Could you please share a little bit more info on useing dummy table? Are you using coding to choose color?

 

Thanks in advance

Kavya123 Frequent Visitor
Frequent Visitor

Re: Change Colors in Bar Chart by selecting color button

Hi,

 

Thank you so much it worked...

Highlighted
sturlaws Regular Visitor
Regular Visitor

Re: Change Colors in Bar Chart by selecting color button

@ryan_mayu, off course,

 

First create a stand alone table, tableColor, with a column with the numbers 1 to 4.

On this column, create a measure like this: 

MeasureColor = if(HASONEVALUE(TableColor[Column1]);min(TableColor[Column1]);1)

Create a scatterplot, put column1 from Table on Details, Legend and y-axis.
 
Then create for example a bar chart on some other data in your model. In this chart, go to Formatting-> Data colors -> Advanced controls.  Change to Format by Rule, and based it on MeasureColor. rules.PNG 
The datacolor of the bar chart will now change according to the value of measureColor, which again will change value when TableColor is filtered. If TableColor is not filtered the default value of measureColor=1
 
Regards,
Sturla
ryan_mayu Established Member
Established Member

Re: Change Colors in Bar Chart by selecting color button

@sturlaws

 

Thanks for the sharing. That's very interesting. I will try that.