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

Count occurrences per number of days between two dates

Hi,

I am using =Max([Time Period])-Min([Time Period]) to get the number of days between to date ranges per Visitor.

Visitor 1 --- 01/02/2013
Visitor 1 --- 03/03/2013
Visitor 2 --- 01/03/2013
Visitor 2 --- 03/03/2013

Dimension = Visitor, Formula =Max([Time Period])-Min([Time Period])

my result list looks like this:
17
16
16
16
15
15
14
14
14

Now I would like to get count per number (occurrences) days and show this as chart.

17 – 1
16 – 3
15 – 2
14 – 3


LOAD [Time Period],
Visitor
FROM
[visitor.xlsm]
(
ooxml, embedded labels, header is 1 lines, table is [IS1]);

Thank you

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try a calculated dimension:

=aggr(Max([Time Period])-Min([Time Period]), Visitor)

and as expression

=count(distinct Visitor)

View solution in original post

4 Replies
swuehl
MVP
MVP

Try a calculated dimension:

=aggr(Max([Time Period])-Min([Time Period]), Visitor)

and as expression

=count(distinct Visitor)

Not applicable
Author

in your chart expression , you can use Count(Formula)

Not applicable
Author

Hi,

First of all I would recommend that you split the Time Period field in the script. So you have a Min Time Period and a Max Time Period by Visitor. So your script would look something like this.

LOAD

         Visitor,

     Date(Min([Time Period])) AS MinDate,

     Date(Max([Time Period])) AS MaxDate,

FROM
[visitor.xlsm]
(
ooxml, embedded labels, header is 1 lines, table is [IS1])

Group By Visitor

;

To achieve what you are looking for.

Right click on the tab > New Sheet Object > Chart > Select Bar Chart > Select Next >Dimensions > Select Add Calculated Dimension > Add the following expression > MaxDate - MinDate > Select Ok > Select Next > Add the following Expression in the Expression window > Count(Visitor) > Select Ok

Hope this helps.

Thanks

Zohaib

Not applicable
Author

That's it.


Thanks a lot.