Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

summation of date interval.

Hello Team,

I have two dates date1 and date2, I am finding difference between the two dates using interval function in an expression of straight table

Here I want the sum of whole expression.

my expression is

if(condition,interval(sum(date2-date1),'hh:mm','00:00')

which giving me difference in hours and minutes along with this I am able to find sum of the expression but in few cases where condition won't satisfy my expression will take '00:00' , in this cases the total sum of expression is not displaying.

Can someone suggest me the solution for this.

Thanks!!!

1 Solution

Accepted Solutions
Not applicable
Author

Thanks all for your support ,

It got resolved by changing "Expression Total' to "Sum Of Rows" option in expression tab of straight table.

View solution in original post

11 Replies
Gysbert_Wassenaar

Try 0 instead of a text value. Zero's can be summed and text values can't.

if(condition,interval(sum(date2-date1),'hh:mm'),0)


talk is cheap, supply exceeds demand
Not applicable
Author

I tried with that, in this case the whole sum is showing as 0.

sasiparupudi1
Master III
Master III

You are missing a bracket in your expression and you need to use 0 in the else condition as Gysbert says

if(condition,interval(sum(date2-date1),'hh:mm'),0)

HTH

Sasi

sasiparupudi1
Master III
Master III

try

Interval(0,'hh:mm')

Not applicable
Author

my expression in this thread was typo error, it is

if(condition,interval(sum(date2-date1),'hh:mm')) and I tried with both interval() and 0, still it is showing 0 or 00:00.


Thanks.

sasiparupudi1
Master III
Master III

try

if(condition,sum(interval(date2-date1,'s')),0)


then you can divide the result by 60/60 to get the total hours

HTH

Sasi

Not applicable
Author

Thanks Sasi,

I tried all these before, didn't work.

Any other solution to sum the numbers in string format.

sasiparupudi1
Master III
Master III

Please share your app

sunny_talwar

Try this may be:

If(Condition, Interval(sum(date2-date1),'hh:mm'), Interval#('00:00', 'hh:mm'))