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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Conditionally formatting a date field

I am having a problem conditoinally formatting a date colum after I have selected do show the "latest" date.  The color column (based on field) is not matching with the correct date.  Any suggestions or alternative methods to fix?  Thanks!!!

nbarjesteh_0-1637337992210.png

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a measure ,then use contiditional format.

1.create a measure .

Measure = 
var _diff=DATEDIFF(MAX('Table'[Order Date]),TODAY(),MONTH)
return SWITCH(TRUE(),_diff<1,"white",_diff<2,"yellow",_diff<3,"orange","red")

2.use conditional format.

vyalanwumsft_0-1637638168121.pngvyalanwumsft_1-1637638188315.png

The final output is shown below:

vyalanwumsft_3-1637638256913.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a measure ,then use contiditional format.

1.create a measure .

Measure = 
var _diff=DATEDIFF(MAX('Table'[Order Date]),TODAY(),MONTH)
return SWITCH(TRUE(),_diff<1,"white",_diff<2,"yellow",_diff<3,"orange","red")

2.use conditional format.

vyalanwumsft_0-1637638168121.pngvyalanwumsft_1-1637638188315.png

The final output is shown below:

vyalanwumsft_3-1637638256913.png

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , Logic is not very clear, but you need to create a color measure 

 

example

 

Colour =
SWITCH(TRUE(),
max('Table'[Month Year]) = "Jan-2020", "red",
Max('Table'[Month Year]) < "Feb-2020", "orange",
//keep on adding
"green")

Measure =
Switch(true(),
max(Table[Column]) = "R1" , "Red" ,
max(Table[Column]) = "R2" , "Green" ,
max(Table[Column]) = "R3" , "Pink "
)

 

 

and use that is conditional formatting using field value option

 

PowerBI Abstract Thesis: How to do conditional formatting by measure and apply it on pie?: https://youtu.be/RqBb5eBf_I4

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I tried to create a color measure column from DAX below and use it to base the color of the date;

sorry-I do not understand your example:

Color column = SWITCH(true(),
DATEDIFF(today(),Sheet1[Order Date],MONTH)>-2 && DATEDIFF(today(),Sheet1[Order Date],MONTH)<=-1, "yellow",
DATEDIFF(today(),Sheet1[Order Date],MONTH)>-3 && DATEDIFF(today(),Sheet1[Order Date],MONTH)<=-2, "orange",
DATEDIFF(today(),Sheet1[Order Date],MONTH)>-14 && DATEDIFF(today(),Sheet1[Order Date],MONTH)<=-3, "red",blank())

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.