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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Avg Question

Hi,

I'd like to calculate the average of visitors.
A visit should only be counted if it's on different days. e.g. Elvis P. visited 2x on 20.05.2008 -> 1 Visit
I would like to calculate the average per visitor dependent on the selected date/ date range.

Average for Elvis P.:
=========================
Elvis visited on 02.01.2008, 03.01.2008, 05.05.2008, 22.05.2008, 31.07.2008


Average 01/2008: 2
Average 05/2008: 3

Average 01/2008 - 06/2008 = 5/2(Months) = 2.5
Average 2008: 6/12 = 0.5

Is there a way to get this dynamic so that I can switch from months to calendar weeks.
I guess I also have to use a calendar script in this case?

Thanks

Regards.

Aloah

1 Reply
johnw
Champion III
Champion III

I think the attached is what you're looking for. To get the count of months, I expanded your calendar to include all dates in 2008. To handle switching from months to weeks, I added a visit_period cyclic group. Then I used this expression:

count(distinct visit_date) / count(total distinct visit_period)