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

AVG of the first dates of the selection

Hi,

Im making an applications with different tables with many data. Lets look at his example what causes the trouble (This is just an example, with dummy data to make the problem clear):

IDDD_AANVRDD_AFDOENING
11-1-20014-1-2001
14-1-20018-1-2001
18-1-200118-1-2001
118-1-200123-1-2001
21-1-20013-1-2001
23-1-20018-1-2001
28-1-200118-1-2001
218-1-200121-1-2001
31-2-20014-2-2001
34-2-20018-2-2001
38-2-200118-2-2001

I want to take the AVG of the amount of days between the begin and end dates of the ID's, but only from the first begin and end date.  So far i have this expression:

 

AVG(if(DD_AFDOENING >= DD_AANVR, DD_AFDOENING - DD_AANVR))'

Does somebody know how i can solve this?

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Not quite sure what you want.

Average of days between the minimum DD_AANVR and maximum DD_AFDOENING per ID:

avg(aggr(max(total <ID> DD_AFDOENING) - min(total <ID> DD_AANVR),ID))

Average of days between the first DD_AANVR and first DD_AFDOENING per ID:

avg(aggr(FirstSortedValue(DD_AFDOENING - DD_AANVR, DD_AANVR),ID))

see attached qvw


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar

Not quite sure what you want.

Average of days between the minimum DD_AANVR and maximum DD_AFDOENING per ID:

avg(aggr(max(total <ID> DD_AFDOENING) - min(total <ID> DD_AANVR),ID))

Average of days between the first DD_AANVR and first DD_AFDOENING per ID:

avg(aggr(FirstSortedValue(DD_AFDOENING - DD_AANVR, DD_AANVR),ID))

see attached qvw


talk is cheap, supply exceeds demand
Not applicable
Author

The 2nd one did the trick thanks.