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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors