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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
swaggerboy69
Helper IV
Helper IV

Help with Date Conditional Formatting (Due Date)

Hello!

 

I need help in using conditional formatting for dates.

I have a column for due dates and would want a color coded value when it's far from due date, almost due date and beyond due date.

 

For example.

I want Task Number and Due date background turned GREEN if it's far from it's due date.

ORANGE if it's close to its due date and

RED if it's beyond its due date.

 

cond form.JPG

1 ACCEPTED SOLUTION

Hi @swaggerboy69 ,

 

This is a measure and you should replace the ";" by ",".

 

CondittionalFormatting =
VAR number_of_days =
    SELECTEDVALUE ( 'Table'[Due Date] ) - TODAY ()
RETURN
    SWITCH (
        TRUE (),
        number_of_days < 0, "Red",
        number_of_days < 10, "Orange",
        "Green"
    )

 

The number_of_days is a variable is calculated on top as you can see tha make the difference between the due date and today.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

6 REPLIES 6
MFelix
Super User
Super User

Hi @swaggerboy69 ,

 

What is the condition to have it Close/Far from due date?

 

If you create a measure similar to the one below you can have the desired result:

 

CondittionalFormatting =
VAR number_of_days =
    SELECTEDVALUE ( 'Table'[Due Date] ) - TODAY ()
RETURN
    SWITCH (
        TRUE ();
        number_of_days < 0; "Red";
        number_of_days < 10; "Orange";
        "Green"
    )

Just adjust the 10 days to whatever value you need then use it as your condittional formatting:

 

Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hello! Thank you for your response.

Should I just add a measure?

Where do I get number_of_days?

I get red lines. Sorry I'm, not too good with codes.

 

cond form2.JPG

Hi @swaggerboy69 ,

 

This is a measure and you should replace the ";" by ",".

 

CondittionalFormatting =
VAR number_of_days =
    SELECTEDVALUE ( 'Table'[Due Date] ) - TODAY ()
RETURN
    SWITCH (
        TRUE (),
        number_of_days < 0, "Red",
        number_of_days < 10, "Orange",
        "Green"
    )

 

The number_of_days is a variable is calculated on top as you can see tha make the difference between the due date and today.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Great. That worked. However how do I apply it to the table visual?

I only get the words.

 

cond form3.JPG

Hi @swaggerboy69 ,

 

You need to select the dates and task number and all the columns you need  then slected the condittional formatting and aplly the value of the measure see images below:

 

MFelix_0-1603976350304.png

MFelix_1-1603976419332.png

MFelix_2-1603976432578.png

MFelix_3-1603976441560.png

 

MFelix_4-1603976459607.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thanks Miguel! It worked!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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