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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
JaroslavZB
New Member

Date sort by color

Hello, 

 

II need to make the dates in the table different in color according to the expiration date of the product. If there are more than 3 months from today to the end of the expiration date, the dates will be green, if there will be less than 3 months from today to the end of the expiration date, the date will be orange, and if today is already after the expiration date, the date will be red. 

 

Do you know how to do that ? 

 

Thank you. 

 

Jaroslav

1 REPLY 1
ppm1
Solution Sage
Solution Sage

You can use a measure expression like this one and use it in the backgroun conditional formatting for the ExpDate field in a table visual.

DateColor =
VAR maxdate =
    MAX ( Expiries[ExpDate] )
VAR DaysUntilExpiry =
    INT ( maxdate - TODAY () )
VAR color =
    SWITCH (
        TRUE (),
        DaysUntilExpiry >= 90, "Green",
        DaysUntilExpiry >= 0, "Orange",
        "Red"
    )
RETURN
    color

ppm1_0-1675616072651.png

Pat

Microsoft Employee

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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