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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
predicteam
Contributor II
Contributor II

Difference between two timestamps if some conditions are verified

Hello guys,

I have the following dataset: 

Schermata 2022-10-25 alle 15.36.09.png

I would like to have a KPI with the average value (in minute) of the difference between the two timestamps (task_date) with task_name 'check' and 'close'. The average value should be calculated once the data are aggregated for "acquisition_code".

In this example, my result should be 8 minutes, calculated as average value of 11 minutes and 5 minutes.

Please, could you help me in having a correct KPI formula?

Thanks

Labels (4)
1 Solution

Accepted Solutions
BrunPierre
Partner - Master II
Partner - Master II

Do you want to exclude values 1 and 2 from idTask? Here's how...

=Interval(Avg({<idTask-={1,2}>}Aggr(Only({<task_name={'close'}>}task_date) - Only({<task_name={'check'}>}task_date),acquisition_code)),'m')

View solution in original post

4 Replies
BrunPierre
Partner - Master II
Partner - Master II

Like this, perhaps.

BrunPierre_3-1666763444840.png

=Interval(Avg(Aggr(Only({<task_name={'close'}>}task_date) - Only({<task_name={'check'}>}task_date),acquisition_code)),'m')
predicteam
Contributor II
Contributor II
Author

Dear BrunPierre,

thank you so much!! It works great!

Just the last question: how could I change the formula to exclude from the calculation, for example, data with idTask = 1 and idTask = 2?

Thank you a lot again,

Marco

BrunPierre
Partner - Master II
Partner - Master II

Do you want to exclude values 1 and 2 from idTask? Here's how...

=Interval(Avg({<idTask-={1,2}>}Aggr(Only({<task_name={'close'}>}task_date) - Only({<task_name={'check'}>}task_date),acquisition_code)),'m')

predicteam
Contributor II
Contributor II
Author

Thanks you very very much! It works perfectly!