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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Bryan_Schmidt
Helper I
Helper I

Unable to change color of columns in visual

I have a series of four visuals per year over a five year period (20 total). Each year uses a specific date range filter. I need to have the color in each visual the same for each year. The "default" color for 2019 is blue and I'm trying to change it to pink. Under Columns in format visual I have the categories set to All and pink is shown as the desired color. I've tried resetting the date ranges and also changing the field used for the legend with no change in results. Everytime I change the date range filter the color changes automatically but will not change to what I specifiy. I've tried conditional formatting but was not successful. What should I try next?

Bryan_Schmidt_0-1705464351710.png

Bryan_Schmidt_1-1705464385950.png

 

1 ACCEPTED SOLUTION

Thanks for providing the syntax. I will keep it for future use. 

 

I found a solution, as least as it applies to my current project. The steps are shown below and must be done in the order shown. Please note this can impact other visuals so when completed check to see if the colors on other graphs need changing. I don't know why it works but am grateful it does.

  1. Uncheck the date range filter
  2. Under "Format visual" expand Columns section and select the date range under "Apply settings to Categories" (date ranges now appear instead of amount ranges)
  3. Select desired color
  4. Select date range in filter box under Filters

 

 

View solution in original post

4 REPLIES 4
Ritaf1983
Super User
Super User

Hi @Bryan_Schmidt 
If I understood you correctly you want to apply color that depends on the field that is not shown in the graph (date).
To get the desired result you have to use conditional formatting.
For example :
if I have a slicer/filter like in the picture:


Ritaf1983_0-1705472620435.png

and want the 2020 be green and others orange, I need to create flag measures like:

flag = if(min('Calendar'[Year])=2020 && MAX('Calendar'[Year])=2020 ,"Green","Orange")
and then I can get it to the columns' color with conditional formatting functionality :
Ritaf1983_1-1705472779887.pngRitaf1983_2-1705472811667.png

result :

Ritaf1983_3-1705472848357.pngRitaf1983_4-1705472875553.png

pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

You are correct in that I want to apply a color that depends on the field that is not shown in the graph (date). I want to use pink for 2019, dark blue for 2020, orange for 2021, purple for 2022, and light blue for 2023.

 

I'm guessing I need to create a new measure (flag) to do this but am not sure on what field to do it. My fields are shown below. The Year field has values from 2019 to 2023 and the YRcode (year code) has values from 4YP (for 2019), 3YP (for 2020), 2YP (for 2021), PY (for 2022), and CY (for 2023). Please advise how the syntax should be written for all five years and on what field the new measure should be added.

Bryan_Schmidt_0-1705533237874.png

 

Hi @Bryan_Schmidt 
The syntax is something like this:

flag =
var
selected_year = SELECTEDVALUE('Calendar'[Year])
return
SWITCH (selected_year,
    2019 ,"pink",
     2020 ,"dark blue",
    2021,"orange",
    2022,"purple",
    2023,"light blue",
    "Grey" )
Result :
Ritaf1983_0-1705546769566.png

the updated pbix is attached

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Thanks for providing the syntax. I will keep it for future use. 

 

I found a solution, as least as it applies to my current project. The steps are shown below and must be done in the order shown. Please note this can impact other visuals so when completed check to see if the colors on other graphs need changing. I don't know why it works but am grateful it does.

  1. Uncheck the date range filter
  2. Under "Format visual" expand Columns section and select the date range under "Apply settings to Categories" (date ranges now appear instead of amount ranges)
  3. Select desired color
  4. Select date range in filter box under Filters

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors