Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
nirav_bhimani
Partner - Specialist
Partner - Specialist

Problem while Calculating date difference in a table using above().

Hi Everyone,

I am using the following expression, Using that I am not getting the output as I want, In that when container no is changed then also its calculating event difference with the one above eventdate of different container. I want first event difference should be –  or 0 for each container rather than calculating event diff with its above event date of each, I want output as following table.

 

SET ANALYSIS EXPRESSION:

if(RowNo(TOTAL )=1,null(), Interval(Timestamp (Above (Total
EVENT_DATE) - ( EVENT_DATE) ),'D hh:mm') )

Straight Table:

Container No.EventEvent DateDate Difference(In days)
aaa01-01-2013 13:00-
abb02-01-2013 14:001
acc05-01-2013 16:003
add06-01-2013 18:001
baa05-01-2013 01:00

-

bee08-01-2013 00:003
bdd10-01-2013 01:002
bcc15-01-2013 13:006
bee17-01-2013 13:002
caa10-01-2013 15:00-
cbb11-01-2013 02:000
ccc16-01-2013 03:005
cdd18-01-2013 05:002

Please provide any solution for the same.

Thanks & Regards, 

Nirav Bhimani

1 Solution

Accepted Solutions
swuehl
MVP
MVP

If your interval calculation needs to be sensitive to selection (i.e. you need to do this in the chart), I think all you need to do is using above() without the TOTAL qualifier and using only two dimensions, [Container No.] and [Event Date] to create a line per single distinct event.

Then, you can show your Event name by using an expression like

=only(Event)

and your intervals like

=round([Event Date]-above([Event Date]))

(I wasn't quite sure how you want to handle the fractions of a day, the expression is replicating the result table you posted above. Another idea is to use

=floor([Event Date])-above(floor([Event Date]))

Using two dimensions, the standard behaviour of above() function will return what you want on change of Container No. (assuming that your columns are sorted by [Container No.], [Event Date] asc).

See also attached.

Stefan

View solution in original post

2 Replies
Gysbert_Wassenaar

You should do this in the script, not in an expression. See attached qvw.

But if you feel you must use an expression try this one: if(above(total [Container No.])=[Container No.], interval( [Event Date]-above(total [Event Date]),'d')). And make sure your chart is sorted on Container No. first and then Event Date.


talk is cheap, supply exceeds demand
swuehl
MVP
MVP

If your interval calculation needs to be sensitive to selection (i.e. you need to do this in the chart), I think all you need to do is using above() without the TOTAL qualifier and using only two dimensions, [Container No.] and [Event Date] to create a line per single distinct event.

Then, you can show your Event name by using an expression like

=only(Event)

and your intervals like

=round([Event Date]-above([Event Date]))

(I wasn't quite sure how you want to handle the fractions of a day, the expression is replicating the result table you posted above. Another idea is to use

=floor([Event Date])-above(floor([Event Date]))

Using two dimensions, the standard behaviour of above() function will return what you want on change of Container No. (assuming that your columns are sorted by [Container No.], [Event Date] asc).

See also attached.

Stefan