cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
umershamshad
Regular Visitor

Measure to display date in different colors based on specific rules.

I'm trying to create a measure which will display last refreshed date of Power BI dataset in different colors, with the following criteria:

  • Green, if last refreshed date = Today
  • Yellow, if last refreshed date = Today - 1 (Yesterday)
  • Red, if last refreshed date is before that

I've created the following measure:

 

LastRefresh =
VAR RefreshDate = MAX(LastRefreshed[LastRefreshedDate])
VAR TodayDate = MAX(LastRefreshed[Today])

RETURN
IF(
RefreshDate = TodayDate, "#00FF00",
IF(
RefreshDate = TodayDate - 1, "#FFFF00", "#FF0000"))
 
The table has only two fields:
umershamshad_0-1660201797781.png

 

This is the result I'm getting:

umershamshad_0-1660201966473.png

 

I want to display the date in  specific color instead of RGB code. Can someone help me?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@umershamshad , Use the measure last refresh in the table and color measure in conditional formatting using the field value option.

 

refer

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...
https://amitchandak.medium.com/power-bi-where-is-the-conditional-formatting-option-in-new-format-pan...

 



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s || 50+Power Query List Functions : Learn Power Query List
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@umershamshad , Use the measure last refresh in the table and color measure in conditional formatting using the field value option.

 

refer

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/...
https://amitchandak.medium.com/power-bi-where-is-the-conditional-formatting-option-in-new-format-pan...

 



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s || 50+Power Query List Functions : Learn Power Query List
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show episode 9

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 25

Ted's Dev Camp - August 25, 2022

Watch Session 25 of Ted's Dev Camp.

Top Solution Authors