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

This widget could not be displayed.

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
sifatnabil
Specialist
Specialist

Sum time interval in chart

Hi all,

I can successfully calculate the time difference between 2 datetimes for each order using:

Interval(timestamp(max(RemoveTime))-timestamp(min(InsertTime)))

However, I want to sum the total time difference by client. When changing the dimension to client and using this expression, the sum is not correct. What expression should I use? Thanks.

This widget could not be displayed.
1 Solution

Accepted Solutions
sunny_talwar

May be like this:

Interval(Sum(Aggr(Interval(TimeStamp(Max(RemoveTime))-TimeStamp(Min(InsertTime))), OrderID)))

UPDATE:

or this based on the fact that you really don't need TimeStamp function as mentioned by Stefan below

Interval(Sum(Aggr(Max(RemoveTime)-Min(InsertTime), OrderID)))

View solution in original post

This widget could not be displayed.
8 Replies
sunny_talwar

May be like this:

Interval(Sum(Aggr(Interval(TimeStamp(Max(RemoveTime))-TimeStamp(Min(InsertTime))), OrderID)))

UPDATE:

or this based on the fact that you really don't need TimeStamp function as mentioned by Stefan below

Interval(Sum(Aggr(Max(RemoveTime)-Min(InsertTime), OrderID)))

This widget could not be displayed.
rrsrini2907
Creator
Creator

Hi,

Could you post a sample app?

Regards,

Srini.

This widget could not be displayed.
miguelbraga
Partner - Specialist III
Partner - Specialist III

Hi Sifat,

Can you please share a qvw sample with your issue so that we can see what's you're doing wrong?

Regards,

MB

This widget could not be displayed.
miguelbraga
Partner - Specialist III
Partner - Specialist III

Even though,

You could make a field in your table like this:

YourTableName:

LOAD      *,

               Interval(timestamp(max(RemoveTime))-timestamp(min(InsertTime))) as DifTime

Resident YourLoadedTable;

Drop Table YourLoadedTable;

Then you can use this expression in your chart:

  • Sum(Aggr(DifTime, ClientID))

Regards,

MB

This widget could not be displayed.
swuehl
MVP
MVP

Just a note, you don't need to format your fields using TimeStamp() when you are doing calculations on them and reformat using Interval() anyway:

=Interval(

      Sum( Aggr( Max(RemoveTime) - Min(InsertTime), OrderField))

)

This widget could not be displayed.
sifatnabil
Specialist
Specialist
Author

For some reason, this doesn't work. But if we amend it using swuehl‌ 's formula, it works, i.e. by using interval in the outer brackets:

Interval(sum( Aggr( Max(RemoveTime) - Min(InsertTime), ORDER_ID)))

This widget could not be displayed.
sifatnabil
Specialist
Specialist
Author

Sent in my reply before I saw your update. Thanks swuehl‌ as well.

This widget could not be displayed.
sunny_talwar

Interval is just a formatting function, I am not sure how this can influence the results? You might be seeing not be seeing the numbers because they are too small, but by adding Interval() or using number tab for formatting, you would end up seeing the same results.

This widget could not be displayed.