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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
JMST
Frequent Visitor

Coloring Matrix according to Dates

Hi All!

 

I want to coloring a matrix depending on the dates, for instance, if I have dates before today I want to coloring the background in red, if I have dates between today+6 months I want to coloring the background in yellow and green in other cases.

Does anyone have any idea how to do it?
JMST_0-1697542530964.png

Thank you in advanced for your help!

Best regards

2 ACCEPTED SOLUTIONS
Ritaf1983
Super User
Super User

Hi @JMST 
You can create DAX measure for color flag :

Flag = if (MAX('Table'[Date]) < TODAY(),"red",
       
         if (max('Table'[Date])>TODAY() && DATEDIFF(  max('Table'[Date]),TODAY(),MONTH)>=-6, "yellow",
          "green"))
And then use it as a rule of condition
Ritaf1983_0-1697543599386.png

Link to a sample file 

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

View solution in original post

Uzi2019
Super User
Super User

Hi @JMST 
Please try the following solution. Hardly takes 5 mins.


1) Create column for Next 6 month date

Today_ = DATE(Year(TODAY()),MONTH(TODAY())+6,DAY(TODAY()))

2) create color measure for conditional formatting
Color Date1 =
            SWITCH(TRUE(),
                          max('Test Date'[Date Future])< TODAY(),"Red",
                          AND(MAX('Test Date'[Date Future])>=TODAY(), (min('Test Date'[Date Future])<MIN('Test                                            Date'[Today_]))),"yellow",
                         "Green"
                           )
 
    3) apply conditional formatting on cell element
       select table > cell element > Field value >select color measure
Uzi2019_2-1697548811000.png

 



Uzi2019_0-1697548560208.png

 

then you will get this color formatted column.

 

Uzi2019_1-1697548603337.png


If my post helps please give kudos and accept it as a solution!
Thanks

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

View solution in original post

3 REPLIES 3
JMST
Frequent Visitor

Thank you for your answer! It works perfect!

Uzi2019
Super User
Super User

Hi @JMST 
Please try the following solution. Hardly takes 5 mins.


1) Create column for Next 6 month date

Today_ = DATE(Year(TODAY()),MONTH(TODAY())+6,DAY(TODAY()))

2) create color measure for conditional formatting
Color Date1 =
            SWITCH(TRUE(),
                          max('Test Date'[Date Future])< TODAY(),"Red",
                          AND(MAX('Test Date'[Date Future])>=TODAY(), (min('Test Date'[Date Future])<MIN('Test                                            Date'[Today_]))),"yellow",
                         "Green"
                           )
 
    3) apply conditional formatting on cell element
       select table > cell element > Field value >select color measure
Uzi2019_2-1697548811000.png

 



Uzi2019_0-1697548560208.png

 

then you will get this color formatted column.

 

Uzi2019_1-1697548603337.png


If my post helps please give kudos and accept it as a solution!
Thanks

Don't forget to give thumbs up and accept this as a solution if it helped you!!!
Ritaf1983
Super User
Super User

Hi @JMST 
You can create DAX measure for color flag :

Flag = if (MAX('Table'[Date]) < TODAY(),"red",
       
         if (max('Table'[Date])>TODAY() && DATEDIFF(  max('Table'[Date]),TODAY(),MONTH)>=-6, "yellow",
          "green"))
And then use it as a rule of condition
Ritaf1983_0-1697543599386.png

Link to a sample file 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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