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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
hp13
Contributor II
Contributor II

Count occurrences based on dates

Team,

I am new to Qlik and I am struggling on functions e.g. aggr() and count() not sure how to achieve the following?

 

Data:

1, PERSON1, 4/1/2024

2, PERSON1, 4/3/2024

3, PERSON1, 4/10/2024

4, PERSON2, 4/1/2024

5, PERSON2, 4/2/2024

6, PERSON1, 4/11/2024

 

Below is the desired output:

Person1: 5 Occurrences in April

Person2: 2 Occurrences in April

Similarly for the other months......

 

Any help would be appreciated! Thanks in advance 🙂

 

1 Solution

Accepted Solutions
MatheusC
Specialist II
Specialist II

@hp13 

Create a monthname field in your script:

Load
MonthName(Data) as MonthYear,

Then make your expression bringing the number of people per month.

// static for Apr 2024

count({<MonthYear={'Apr 2024'}>} customers)

// or dynamic, this is an example and your date periods might be different, you may need to adjust

count({<MonthYear={"$(=Date(max(MonthYear)-1, 'MMM YYYY'))"}>} customers) -> Apr 2024

count({<MonthYear={"$(=Date(max(MonthYear), 'MMM YYYY'))"}>} customers) -> May 2024


Regarts, Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!

View solution in original post

2 Replies
MatheusC
Specialist II
Specialist II

@hp13 

Create a monthname field in your script:

Load
MonthName(Data) as MonthYear,

Then make your expression bringing the number of people per month.

// static for Apr 2024

count({<MonthYear={'Apr 2024'}>} customers)

// or dynamic, this is an example and your date periods might be different, you may need to adjust

count({<MonthYear={"$(=Date(max(MonthYear)-1, 'MMM YYYY'))"}>} customers) -> Apr 2024

count({<MonthYear={"$(=Date(max(MonthYear), 'MMM YYYY'))"}>} customers) -> May 2024


Regarts, Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
hp13
Contributor II
Contributor II
Author

Thank you so much @MatheusC! This helps. I really appreciate it.