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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
ievazal
Frequent Visitor

DateTime comparisons

Hello!

 

I have a table that shows data on when visits are created for different buildings and when the visitor has checked-in.

 

BuildingVisit created onCheck-in time
A1-08-2023 11:03:002-08-2023 14:00:00
B2-08-2023 12:00:002-08-2023 13:00:00
C4-08-2023 12:02:024-08-2023 14:00:00
D5-08-2023 9:00:057-08-2023 8:05:00

 

How could I check if a visit has been created after 4PM the previous day the visitor has come in and bring back the amount of such visits?

 

Thank you in advance!

1 REPLY 1
christinepayton
Most Valuable Professional
Most Valuable Professional

SQL BI has a good article on how to add/remove date time in measures here:

https://www.sqlbi.com/blog/alberto/2019/03/25/using-dax-with-datetime-values/

 

You could use variables to store all the things you're comparing. My roundabout guesstimate to get the 4pm the day before for comparison would be to subtract a day from the given date, convert it to date only, then convert it back to date time and add the hours up to 4pm to it. Then you can compare it to the date field in your data and return a true/false if it's greater than or less than the 4pm prior day. 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.