Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Converting number (already hrs) to time format

Hello Everybody,

I have a calculation where I sum up numbers (in s) to hours (by dividing by 3600)  so something like this:

((sum(if(LabelField1='sec',valueField1)))/3600)

Which returns a number like 51.473

The customer wants to see this now in the format hh;mm;ss though.

When changing the presentation to Time i get 11:21:36

Also, since I already calculate it in hrs that change would be wrong anyway.

Does anybody know how to convert the 51.473 (hrs) to hh;mm;ss time format?

1 Solution

Accepted Solutions
maxgro
MVP
MVP

interval(((sum(if(LabelField1='sec',valueField1)))/3600) / 24, 'hh:mm:ss')

or expression without interval, format as interval in number tab

((sum(if(LabelField1='sec',valueField1)))/3600) / 24

View solution in original post

7 Replies
maxgro
MVP
MVP

51.473 / 24

then use interval to format


interval (51473/24, 'hh:mm:ss')

Anonymous
Not applicable
Author

so you mean change the formular to:

Interval((sum(if(LabelField1='sec',valueField1)))/3600,'hh:mm:ss'

?

because this is not changing anything.

Not applicable
Author

Interval((sum(if(LabelField1='sec',valueField1)))/(3600*24),'hh:mm:ss')

This will change your time to number of days (before decimal part) and after decimal part will be time part.

maxgro
MVP
MVP

interval(((sum(if(LabelField1='sec',valueField1)))/3600) / 24, 'hh:mm:ss')

or expression without interval, format as interval in number tab

((sum(if(LabelField1='sec',valueField1)))/3600) / 24

MarcoWedel

Interval(Interval#(Sum({$<LabelField1={'sec'}>} valueField1) ,'s'))

hope this helps

regards

Marco

Anonymous
Not applicable
Author

Thanks Massimo... I used the second option.. Was easier

MarcoWedel

one performance comparison between the initial Sum(If()) expression and a set expression version:

test data:

QlikCommunity_Thread_168174_Pic7.JPG

QlikCommunity_Thread_168174_Pic6.JPG

set expression:

QlikCommunity_Thread_168174_Pic2.JPG

QlikCommunity_Thread_168174_Pic3.JPG

Sum(If())

QlikCommunity_Thread_168174_Pic5.JPG

QlikCommunity_Thread_168174_Pic4.JPG

hope this helps

regards

Marco