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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
wylee1
New Member

Formulas on calculating the total of time

Hello,

 

Need some advice as I am new to PowerBI. I am trying to calculate the sum time from start time and end time. REfer to below.

DateTimeStart     DateTimeEnd      ToolName                 Operation    User          sumtime
31-Oct-16 9:00   31-Oct-16 17:00   HiSeq 2000 Engg   TrainServ      Bernard       error

 

sumHours = sumx(timeTable, DATEDIFF(timeTable[DateTimeStart], timeTable[DateTimeEnd], SECOND))/3600

 

Please advice how to make it work.Thanks

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @wylee1,

 

You can create a measure like below:

 

TimeInter = DATEDIFF(SUM('Table2'[DateTimeStart]),SUM('Table2'[DateTimeEnd]),SECOND)

 

Or create a calculate column like this:

 

Inter = DATEDIFF('Table2'[DateTimeStart],'Table2'[DateTimeEnd],SECOND)

 

q4.PNG

 

Reference:
DATEDIFF Function (DAX)

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-qiuyu-msft
Community Support
Community Support

Hi @wylee1,

 

You can create a measure like below:

 

TimeInter = DATEDIFF(SUM('Table2'[DateTimeStart]),SUM('Table2'[DateTimeEnd]),SECOND)

 

Or create a calculate column like this:

 

Inter = DATEDIFF('Table2'[DateTimeStart],'Table2'[DateTimeEnd],SECOND)

 

q4.PNG

 

Reference:
DATEDIFF Function (DAX)

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
BhaveshPatel
Community Champion
Community Champion

You can try this measure to get the correct results:

 

TotalHrs:=SUMX(timeTable,([DatetimeEnd]-timeTable[DatetimeStart])*1440/60)

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.