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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Average Duration from multiple dates

Hi,

I'm having a table which contains data as, brand prescribed for users.

for example:

I have data like this,

Username     BrandName     Date

xxx               aaa               30/05/2015

zxc               bbb                01/06/2015

zzx               aaa               02/06/2015

zsd               ccc               03/06/2015

ssxc              ccc               04/06/2015

sas               aaa               05/06/2015

dfdf               bbb               06/06/2015

dsd               bbb               07/06/2015

fsd               aaa               08/06/2015

sas               ccc               09/06/2015

Now i want to get the average duration of each brandname.

i.e Brand name 'aaa' is prescribed 4 times totally.

I need to get the day interval between its prescription date and to find the average.

like,


Sum of time interval =  (02/06/2015-30/05/2015) + (05/06/2015-02/06/2015) + (08/06/2015-05/06/2015)

average = Sum of time Interval / count(Dates).

Kindly help me to achieve this.,

whether by set expression or by script.,

Thanks in advance

Regards

Adith

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try avg(aggr(Interval(max(Date)-min(Date))/count(Date),BrandName)). See attached qvw.


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try avg(aggr(Interval(max(Date)-min(Date))/count(Date),BrandName)). See attached qvw.


talk is cheap, supply exceeds demand
maxgro
MVP
MVP

you can make a straight table chart with

dimension      BrandName

expression     (max(Date)-min(Date)) / count(Date)

Not applicable
Author

Thanks Gysbert !!!

It worked fine.

Regards,

Adith