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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Change of bar color based on date - before and after today

Is it possible to change the color of the bars in a chart, based on date? Values today and after today has another color than before today. I am using this on sales - values to be delivered, and values of backlog

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous , you can achieve this by following these steps.

1)Create a column in your table for holding the difference in date with respect to today's date in days. You can use the following DAX for the column.

Date Difference = DATEDIFF(TODAY(),Sheet1[Sample Date ],DAY)

You'll get a column like this

Aditya_Meshram_0-1625832502608.png

2)Create a bar chart and use conditional formatting based on the Date Difference column to get different colours for values having date equal to and greater than today and for values having date less than today. Go to conditional formatting by clicking on fx Button(Shown below)

Aditya_Meshram_1-1625832870250.png

 

3) Then you can can set the "Format by"  field as "Rules" and use the following rules.

Aditya_Meshram_2-1625833007572.png

The result will look like this. The values with negative date difference have red colour and the values with zero and positive date difference have green colour.

Aditya_Meshram_3-1625833349438.png

The date as of writing this answer is 9th July 2021, so the values for 9th July and above have green color and the values having date before 9th July have red colour.

 

The .pbix file is attached for reference.

Link to the .pbix file. 

 

Regards,

Aditya

 

View solution in original post

6 REPLIES 6
Rui_Reis
Frequent Visitor

I don't see the option to get conditional formating am I using the wrong chart type or version?
I'm using clustered columns chart and line and clusteres columns chart.

Rui_Reis_0-1676549205326.png

 

lcdelgado
Helper I
Helper I

The operations Qtr1 have 3 with -5 days and its not red on the column. I appreciate any help on this matter, thank you 🙁

 

lcdelgado
Helper I
Helper I

Hello! why my graphic doesnt show the red color on the negative values on my graph?

 

lcdelgado_1-1673896051492.png

lcdelgado_2-1673896068640.png

 

Anonymous
Not applicable

This was also exactly what I was looking for - thank you!  I have a 13-month rolling trend chart and wanted to highlight last month vs. last month prior year.  Using your formula to create a "Months Ago" column in my date table did the trick.

 

2022-08-11 11_35_05-KevAnne's Expenses Dashboard - Power BI Desktop.png2022-08-11 11_35_41-KevAnne's Expenses Dashboard - Power BI Desktop.png

Anonymous
Not applicable

Thank you! This is what I'm looking for!

 

Best regards, Ingrid 

Anonymous
Not applicable

Hi @Anonymous , you can achieve this by following these steps.

1)Create a column in your table for holding the difference in date with respect to today's date in days. You can use the following DAX for the column.

Date Difference = DATEDIFF(TODAY(),Sheet1[Sample Date ],DAY)

You'll get a column like this

Aditya_Meshram_0-1625832502608.png

2)Create a bar chart and use conditional formatting based on the Date Difference column to get different colours for values having date equal to and greater than today and for values having date less than today. Go to conditional formatting by clicking on fx Button(Shown below)

Aditya_Meshram_1-1625832870250.png

 

3) Then you can can set the "Format by"  field as "Rules" and use the following rules.

Aditya_Meshram_2-1625833007572.png

The result will look like this. The values with negative date difference have red colour and the values with zero and positive date difference have green colour.

Aditya_Meshram_3-1625833349438.png

The date as of writing this answer is 9th July 2021, so the values for 9th July and above have green color and the values having date before 9th July have red colour.

 

The .pbix file is attached for reference.

Link to the .pbix file. 

 

Regards,

Aditya

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors