Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Don't count anything that happened within 30 minutes

I have:

IDTypeTimestampCount
1A

1/1/2013 1:00

1
1B1/1/2013 1:251
1C1/1/2013 1:291
1D1/1/2013 1:301
1E1/1/2013 1:591
1F1/1/2013 2:071

I want:

IDTypeTimestampCount
1A

1/1/2013 1:00

1
1D1/1/2013 1:301
1F1/1/2013 2:071

Basically, once a record is entered (1/1/2013 1:00), I don't want to count any additional entries until 30 minutes have passed.  Once 30 minutes have passed, I can accept a new record, and the 30 minute timer starts again.  This is for a straight table, and I would prefer to solve it using set analysis than to do it in the script, but I can if needed.  Any ideas?

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

You can't do it entirely in Set Analysis, because Set Analysis expression gets evaluated globally, once per chart, so it can't be sensitive to the value (timestamp) of the previously displayed row.

You can prepare certain flags in the script, but then your choice of "visible" vs. "invisible" transactions becomes rigid, i.e. not dependent of user selections.

What if, based on the user selections, the second line with Type=B becomes the first "available", then the counter should start from that line and not from the first line.

I can't see a very elegant solution here... If your dataset is very small and you are not concerned about scalability, you could use an IF statement and compare the timestamp from the previous line in the chart (using ABOVE()) to the current timestamp.

For a large datasets, you'll have to make some assumptions and pre-calculate some of those rules in the load script.

View solution in original post

2 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

You can't do it entirely in Set Analysis, because Set Analysis expression gets evaluated globally, once per chart, so it can't be sensitive to the value (timestamp) of the previously displayed row.

You can prepare certain flags in the script, but then your choice of "visible" vs. "invisible" transactions becomes rigid, i.e. not dependent of user selections.

What if, based on the user selections, the second line with Type=B becomes the first "available", then the counter should start from that line and not from the first line.

I can't see a very elegant solution here... If your dataset is very small and you are not concerned about scalability, you could use an IF statement and compare the timestamp from the previous line in the chart (using ABOVE()) to the current timestamp.

For a large datasets, you'll have to make some assumptions and pre-calculate some of those rules in the load script.

Anonymous
Not applicable
Author

Hi David,

I tried in the script with date, skipping nine and loading each 10th:

LOAD

date(if(date-peek(date)<10, peek(date), date)) as date,

Amount

FROM ...

So, it should work with time as well.  30 min is 1/48 of a day, so it could be something lkike this (maybe with some adjustments):

if(Timestamp-peek(Timestamp)<(1/48), peek(Timestamp), Timestamp)

Make sure that the data is ordered by Timestamp ascending.

Regards,

Michael