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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

HOW CAN I GET THE FINAL TIME OF THE CALLS?

Hi everyone!

 

I need to calculate the exact time the calls ended.

I have the following data: date, start time and seconds that the call lasted.

Example: 05/12/22 ; 14:30:00; 34 (sec).

The "Start Time" column is in HOUR format and the column containing seconds is in INTEGER format.

How could I calculate the final time? According to the previous example, it should return the following value: 14:30:34.

 

Thank you very much. All the best!

1 ACCEPTED SOLUTION
aj1973
Community Champion
Community Champion

Ok lets rather do it in Power Query

Add a custom column to total the seconds

 

aj1973_0-1667166142960.png

Here is the Code :

Time.Hour([Hour]) * 3600
+
Time.Minute([Hour]) * 60
+
[Second]

 

Then
Add another Custom Column to convert it to Time

aj1973_1-1667166297677.png

and here is the code :

#time(0,0,0) + #duration(0,0,0,[Hour converted to seconds])

 

Finally Change the type of the column to Time

 

Third Option would be this DAX

aj1973_0-1667172837935.png

 

Let me know

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

View solution in original post

6 REPLIES 6
aj1973
Community Champion
Community Champion

Hi @Anonymous 

In Power Query, convert the HOUR column to all Seconds, Add the converted column to the column containing seconds and finaly convert the new column to Time format.

You can do it in DAX as well. The idea is always to render the HOUR column to all seconds...

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

Hi @aj1973 , thank you so much for your answer. 

 

I already have the column with all seconds in a integer format. However, I don't know how to convert the column to Time format. I tried it with the function "Convert" but it returns me "dd:mm:yyyy" instead of "hh:nn:ss".

 

Could you help me? Thank you in advance. 

 

Regards. 

aj1973
Community Champion
Community Champion

Hey @Anonymous 

Firts add a column to covert the time to all seconds

aj1973_0-1667143345028.png

Then add a new column to convert all seconds to Time

aj1973_1-1667143424304.png

 

And here are the 2 DAX codes:

Hour To Sec =
( HOUR ( 'Convert'[Hour] ) * 3600 )
    + ( MINUTE ( 'Convert'[Hour] ) * 60 ) + 'Convert'[Second]
 
Time =
VAR _Hour =
INT ( MOD ( 'Convert'[Hour To Sec], 86400 ) / 3600 )
VAR _Minute =
DIVIDE (
INT ( MOD ( MOD ( 'Convert'[Hour To Sec], 86400 ), 3600 ) ) - 'Convert'[Second],
60
)
RETURN
_Hour & ":" & _Minute & ":" & 'Convert'[Second]

 

 

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

Thanks @aj1973 ! I could get the column with the Time. Nevertheless, the format is in Text and I need it in Time. When I try to change the format the result is: #ERROR in all rows. Why I can't convert it to a Time format? 

 

Regards, 

Bibi

Jara 

 

 

aj1973
Community Champion
Community Champion

Ok lets rather do it in Power Query

Add a custom column to total the seconds

 

aj1973_0-1667166142960.png

Here is the Code :

Time.Hour([Hour]) * 3600
+
Time.Minute([Hour]) * 60
+
[Second]

 

Then
Add another Custom Column to convert it to Time

aj1973_1-1667166297677.png

and here is the code :

#time(0,0,0) + #duration(0,0,0,[Hour converted to seconds])

 

Finally Change the type of the column to Time

 

Third Option would be this DAX

aj1973_0-1667172837935.png

 

Let me know

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Anonymous
Not applicable

Yes! @aj1973 I finally made it!

I solved it through Power Query. Really, thank you so much for your help. I can't be more grateful. 

 

Kind regards, 

Bibi

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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