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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
AndrewKalungi
New Member

DAX Dates Remaining

For DAX calculations, could you please advice how I can calc a column to show number of days it takes for close an issue if I have an initial date and due date. When it approaches 5 days to the due date, the shows a red color, 15 days to due date yellow, 30 days to due date should be green

 

2 ACCEPTED SOLUTIONS
Deku
Community Champion
Community Champion

Adjust the hex codes to the colours you like then apply this measure as condition formatting rule

 

Measure=

Var diff = Datediff( table[due date], today(), day)

Var green = "#aaaaaa"

Var yellow = "#aaaaaa"

Var red = "#aaaaaa"

Return

Switch(

True,

Diff <= 5, red,

Diff <= 15, yellow,

Diff <=30, green

)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

bhanu_gautam
Super User
Super User

@AndrewKalungi You can create a calculated column to determine the number of days between the initial date and the due date.

DaysToClose = DATEDIFF([InitialDate], [DueDate], DAY)

 

You can use a calculated column to determine the color based on the number of days remaining until the due date.

DueDateColor =
SWITCH(
TRUE(),
[DaysToClose] <= 5, "Red",
[DaysToClose] <= 15, "Yellow",
[DaysToClose] <= 30, "Green",
"No Color"
)

 

Go to the visualization where you want to apply the conditional formatting.
Select the field you want to format.
Choose "Conditional Formatting" and select "Background Color" or "Font Color".
Use the DueDateColor column to set the color rules.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

3 REPLIES 3
AndrewKalungi
New Member

Thank you so much. This really helped. 

bhanu_gautam
Super User
Super User

@AndrewKalungi You can create a calculated column to determine the number of days between the initial date and the due date.

DaysToClose = DATEDIFF([InitialDate], [DueDate], DAY)

 

You can use a calculated column to determine the color based on the number of days remaining until the due date.

DueDateColor =
SWITCH(
TRUE(),
[DaysToClose] <= 5, "Red",
[DaysToClose] <= 15, "Yellow",
[DaysToClose] <= 30, "Green",
"No Color"
)

 

Go to the visualization where you want to apply the conditional formatting.
Select the field you want to format.
Choose "Conditional Formatting" and select "Background Color" or "Font Color".
Use the DueDateColor column to set the color rules.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Deku
Community Champion
Community Champion

Adjust the hex codes to the colours you like then apply this measure as condition formatting rule

 

Measure=

Var diff = Datediff( table[due date], today(), day)

Var green = "#aaaaaa"

Var yellow = "#aaaaaa"

Var red = "#aaaaaa"

Return

Switch(

True,

Diff <= 5, red,

Diff <= 15, yellow,

Diff <=30, green

)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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