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

How to calculate sum of Time

Hi Everyone

I want to calculate Sum of Time Diff in KPI without using 'Duration' property. Please view snapshot.

I am using this expression:

Sum(IF(endtime>=starttime,

Interval(endtime-starttime,'hh:mm'),TIME(Interval#('24:00','hh:mm')-Interval(starttime-endtime,'hh:mm'),'hh:mm')

))

If I use number formatting as Auto it gives 0.68 i.e. wrong.

I want the result without using Duration. I want the solution using Expression(Formula).

Please help

qliksense.jpg

1 Solution

Accepted Solutions
sunny_talwar

May be this

Interval(Sum(If(endtime >= starttime, endtime-starttime, MakeTime(24)-starttime-endtime)), 'hh:mm')

View solution in original post

5 Replies
YoussefBelloum
Champion
Champion

hi,

on the screen shot, the TIME DIFF are correct ? if so ? how much would be the correct sum of time ?

OmarBenSalem

If you want to keep it on auto; you'll have to directly format your expression :

time#[Sum(IF(endtime>=starttime,

Interval(endtime-starttime,'hh:mm'),TIME(Interval#('24:00','hh:mm')-Interval(starttime-endtime,'hh:mm'),'hh:mm')

)),'hh:mm')

Shahzad_Ahsan
Creator III
Creator III
Author

Correct SUm of time is 16:19 but it is coming when I use Duration Formating. I want to do with expression

sunny_talwar

May be this

Interval(Sum(If(endtime >= starttime, endtime-starttime, MakeTime(24)-starttime-endtime)), 'hh:mm')

Shahzad_Ahsan
Creator III
Creator III
Author

Thanks Sunny