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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
kirstenvo
Frequent Visitor

DAX - SWITCH returns incorrect results

I am working with the SWITCH solution for a while now but I have noticed a problem, lines with the same DueDate and ReviewedDate still show "Overdue" as a result.

 

I am using the following DAX formula:

Overdue? = SWITCH (TRUE(),ISBLANK([ReviewedDate]) && [DueDate] < TODAY(), "Overdue"[DueDate] < [ReviewedDate]"Overdue"[DueDate] = [ReviewedDate]"On Time""On Time")
 
As you can see in the screenshot, there is a record (DocumentID 4477) with DueDate and ReviewedDate on same time. The outcome should be "On Time" but it is "Overdue". What am I missing?
 
Kind regards,
Kirsten
Screenshot 2022-10-04 140017.png

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

The reviewed date has a time part as well as a date part, so the SWITCH is comparing e.g. 9am to midnight - 9am is after midnight so it counts as overdue.

Change the types of the columns to date, not date/time. You need to do that in Power Query as well as in Power BI desktop otherwise they will display as dates only but will still retain the date/time values.

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

The reviewed date has a time part as well as a date part, so the SWITCH is comparing e.g. 9am to midnight - 9am is after midnight so it counts as overdue.

Change the types of the columns to date, not date/time. You need to do that in Power Query as well as in Power BI desktop otherwise they will display as dates only but will still retain the date/time values.

Hello Johnt75,

 

This was helpfull! Thank you very much!

 

Kirsten

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.