Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi all,
I am trying to calculate a time difference (ideally on hh/mm/ss format) from different rows from earliest timestamp and latest timestamp.
My data contains ID and Timestamp (date/time) columns (and many more). Here is a sample data:
I'm trying to calculate the ddhhmm difference between earliest timestamp and the last one from each ID. So like this:
So the end result should look like this in HH/MM/SS format, DD/HH/MM/SS would be also nice to have:
Any tips?
Thanks,
Jere
Solved! Go to Solution.
Hi jer:
You could do a few measures.
My Data table named Data
Hi @jereaallikko ,
Please check this measure.
Measure =
VAR min_ = CALCULATE(MIN('Table'[timestamp]),ALLEXCEPT('Table','Table'[ID]))
VAR max_ = CALCULATE(MAX('Table'[timestamp]),ALLEXCEPT('Table','Table'[ID]))
var vSeconds=DATEDIFF(min_,max_,SECOND)
var vMinutes=int( vSeconds/60)
var vRemainingSeconds=MOD(vSeconds, 60)
var vHours=INT(vMinutes/60)
var vRemainingMinutes=MOD(vMinutes,60)
var vDays=INT(vHours/24)
var vRemainingHours=MOD(vHours,24)
return
vDays&" "&
vRemainingHours&":"&
vRemainingMinutes&":"&
vRemainingSeconds
Best Regards,
Jay
Hi @jereaallikko ,
Please check this measure.
Measure =
VAR min_ = CALCULATE(MIN('Table'[timestamp]),ALLEXCEPT('Table','Table'[ID]))
VAR max_ = CALCULATE(MAX('Table'[timestamp]),ALLEXCEPT('Table','Table'[ID]))
var vSeconds=DATEDIFF(min_,max_,SECOND)
var vMinutes=int( vSeconds/60)
var vRemainingSeconds=MOD(vSeconds, 60)
var vHours=INT(vMinutes/60)
var vRemainingMinutes=MOD(vMinutes,60)
var vDays=INT(vHours/24)
var vRemainingHours=MOD(vHours,24)
return
vDays&" "&
vRemainingHours&":"&
vRemainingMinutes&":"&
vRemainingSeconds
Best Regards,
Jay
also check out this thread
Hi jer:
You could do a few measures.
My Data table named Data
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |