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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
francesctesi
Contributor III
Contributor III

Calculate average time with the aggr and set analysis function

Hi everyone,

I would like to calculate the average time for exam ID, between two dates.

For this reason, I used the following function:

avg(aggr(DATETIME_FINISH-DATETIME_START, IDEXAM))

However, I would only like to calculate exams, which have the field FLAG_EST = 1 and the field REASON_LATE <> '0'.

Is it possible to apply set analysis to consider exams with these values in the final calculation of the average?

Because if I try to use the filters in different positions, they do not work

 

 

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

@francesctesi  It is difficult to write set expression without looking at granularity of data and expected output, but try below

avg({<FLAG_EST={1},REASON_LATE-={0}>} aggr(sum({<FLAG_EST={1},REASON_LATE-={0}>} DATETIME_FINISH-DATETIME_START), IDEXAM))

View solution in original post

2 Replies
Kushal_Chawda

@francesctesi  It is difficult to write set expression without looking at granularity of data and expected output, but try below

avg({<FLAG_EST={1},REASON_LATE-={0}>} aggr(sum({<FLAG_EST={1},REASON_LATE-={0}>} DATETIME_FINISH-DATETIME_START), IDEXAM))

francesctesi
Contributor III
Contributor III
Author

thanks so much  @Kushal_Chawda