Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
zhj0735
Contributor II
Contributor II

Count the number of records(ID) given three columns of date

I have a dataset of ID and 3 dates (input_date, output_date, and sold_date). And I want to count the number of ID based on 3 different dates  that lies in the time period counted as stock, with my logic being:

=count(if (input_date.autoCalendar.YearMonth='<=$(YRMON)' and output_date.autoCalendar.YearMonth='>$(end of YRMON)' ,[ID]))

However, I ran into problems about how could I define a YRMON that can be used to compare those two dates. I tried creating a master dimension YRMON and realize they are not able to be used in the expression.

I know it is doable by creating such a table in python and visualize it in Qlik Sense, but wondering what is the most efficient way to finish this time of data analysis inside of Qlik Sense? 

Thanks all!

 

Labels (1)
1 Solution

Accepted Solutions
Lauri
Specialist
Specialist

Depending on how many rows of data you have (millions?), the IF method is simplest, and I would write it like this with the date itself (I assume these 3 fields are dates because Qlik created autocalendar fields from them):

=count(if (input_date<=end_dt and output_date >end_dt, [ID]))

View solution in original post

3 Replies
zhj0735
Contributor II
Contributor II
Author

I import another table with the dates. Now the YRMON can be compared to independently. But wondering how am I be able to compare the dates?

I am using: Count( {< [out_service_date.autoCalendar.Date]={">=(end_dt.autoCalendar.Date)"} >} distinct vin)

But it doesnt work.

Thanks,

Lauri
Specialist
Specialist

Depending on how many rows of data you have (millions?), the IF method is simplest, and I would write it like this with the date itself (I assume these 3 fields are dates because Qlik created autocalendar fields from them):

=count(if (input_date<=end_dt and output_date >end_dt, [ID]))

zhj0735
Contributor II
Contributor II
Author

Thanks Lauri. That works great!