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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Value need to convert time in Q Editor

Hello Team,

Need help to convert hh:mm:ss format in query editor for cycle duration column (these values are considered as seconds), This column is in text format

gshastri_0-1600070078091.png

 

1 ACCEPTED SOLUTION
AiolosZhao
Memorable Member
Memorable Member

Hi @Anonymous ,

 

An easy way to solve that:

 

Duration.From([Orderid] / 86400)

 

Value need to convert time in Q Editor.PNG

 

Please try.

Aiolos Zhao





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
AiolosZhao
Memorable Member
Memorable Member

Hi @Anonymous ,

 

An easy way to solve that:

 

Duration.From([Orderid] / 86400)

 

Value need to convert time in Q Editor.PNG

 

Please try.

Aiolos Zhao





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

Proud to be a Super User!




amitchandak
Super User
Super User

@Anonymous , Try like this

Duration(Number.IntegerDivide(Number.FromText([Cycle:duration]),86400) ,Number.IntegerDivide(Number.Mod(Number.FromText([Cycle:duration]),86400),3600),
Number.IntegerDivide(Number.Mod(Number.Mod(Number.FromText([Cycle:duration]),86400),3600),60),
Number.Mod(Number.Mod(Number.Mod(Number.FromText([Cycle:duration]),86400),3600),60)
)

AllisonKennedy
Super User
Super User

Sorry, I don't understand, have you already got the seconds and need HH:MM:SS or do you need to calculate the seconds?

If you have HH::MM:SS and need to get seconds, Split Column by delimiter :
Then rename columns to HourPart, MinutePart, SecondPart
Then do a calculated column:
[HourPart]*3600 + [MinutePart]*60 + [SecondPart] and call this calculated column Seconds

If you have Seconds and need HH:MM:SS, then use Number.Mod() and Number.IntegerDivide() to do the opposite

[HourPart]= Number.IntegerDivide{[Seconds], 3600)
[Seconds2]= Number.Mod([Seconds], 3600)
[MinutePart]= Number.IntegerDivide([Seconds2], 60)
SecondsPart = Number.Mod([Seconds2], 60)

Then merge columns with : as delimiter.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Greg_Deckler
Super User
Super User

@Anonymous Well, if it were DAX you could do it this way: https://community.powerbi.com/t5/Quick-Measures-Gallery/Seconds-2-HHMMSS/m-p/195615#M18

 

Should be able to follow a similar technique in Power Query though. 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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