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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Jeffrey_VC
Helper III
Helper III

Next day after timestamp

Hi everyone,

 

I looking for a solution where I have 2 timestamp and will calculate the differents between them.

When i calculate the differents I get a negative value if the first timestamp is later than the second one, like this.
Travel time is differents in minutes.

Jeffrey_VC_0-1711553402709.png

I need the value 1350 (minutes)
How can I solved this?

 

1 ACCEPTED SOLUTION

Hi,

You are correct I had the wrong idea. This should work:

Column =
var _testNextDay =
IF('Table (31)'[time2]<'Table (31)'[time1],
((DATEDIFF("00.00.00",'Table (31)'[time2],MINUTE) -
DATEDIFF("00.00.00",'Table (31)'[time1],MINUTE))
/60
+24)*60
,

 DATEDIFF('Table (31)'[time1],[time2],MINUTE))
 return
 _testNextDay


Here we take the difference in hours = -1 hour then we compare that to 24 hours and multiply by 60. So here 23*60 = 1380

ValtteriN_0-1711615969951.png

 







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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
ValtteriN
Super User
Super User

Hi,

I assume that if the timestamp is lower we will assume it is on next day. Here is an example on how to build this:

ValtteriN_0-1711562278067.png

 

Dax:

Column =
var _testNextDay =
IF('Table (31)'[time2]<'Table (31)'[time1],
DATEDIFF("00.00.00",'Table (31)'[time2],MINUTE)+720,

 DATEDIFF('Table (31)'[time1],[time2],MINUTE))
 return
 _testNextDay


End result:

ValtteriN_1-1711562675215.png

 

If the time is lower we add 12 hours in minutes (720) and compare the second time to midnight. Otherwise we compare normally.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/








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

Proud to be a Super User!




Thank you @ValtteriN , this works! Thank you for your help.

Hi @ValtteriN ,
Thank you for your quick answer.
Your solution is not the solution that i need.

Time 1: 14:00
Time 2: 13:00

Different is 1350 minutes and not 1500 minutes so you have in your example.

Hi,

You are correct I had the wrong idea. This should work:

Column =
var _testNextDay =
IF('Table (31)'[time2]<'Table (31)'[time1],
((DATEDIFF("00.00.00",'Table (31)'[time2],MINUTE) -
DATEDIFF("00.00.00",'Table (31)'[time1],MINUTE))
/60
+24)*60
,

 DATEDIFF('Table (31)'[time1],[time2],MINUTE))
 return
 _testNextDay


Here we take the difference in hours = -1 hour then we compare that to 24 hours and multiply by 60. So here 23*60 = 1380

ValtteriN_0-1711615969951.png

 







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

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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