Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
9 |