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: 
asheppardwork
Contributor III
Contributor III

How can you use set analysis to count the number of items with a date that is between two other dates

I have a bit of a strange problem; I admit I'm not the best at Set Analysis syntax in Qlik. I am trying to get a count of records where the return_date is between the trigger_date and trigger_date + 30/60/90/180/365/730 days.
I have tried the following formulas to no avail; it either miscounts the 30 days, or doesn't count them, or if it does when I change it to a larger value like 365 days it doesn't count them at all, what am I doing wrong here?

I did try this solution but it does not work for me.

Attempt 1:

=Count({<[Return_Dt.autoCalendar.Date]={">=$([Trigger_Dt.autoCalendar.Date]) <=$([Trigger_Dt.autoCalendar.Date]+30)"}>} Distinct RecordNum)

 

Attempt 2:

=Count({<Return_Dt.autoCalendar.Date={">=$(=Trigger_Dt.autoCalendar.Date) <=$(=Trigger_Dt.autoCalendar.Date+30)"}>} Distinct RecordNum)

 

Attempt 3:

=Count({< [Return_Dt.autoCalendar.Date]= {">=([Trigger_Dt.autoCalendar.Date])  <=([Trigger_Dt.autoCalendar.Date]+30)"} >} Distinct RecordNum)
Labels (1)
11 Replies
marcus_sommer

Your row id might be unique within the source and maybe also in the origin Qlik load. But if there are any join or loop approaches in your script the records might be duplicated. By joining approaches may even recno() and rowno() not unique in regard to the existing records.

Therefore add at the end of your joins and/or the script something like this:

qualify *; x: load *, rowno() as RowNo resident YourTable; unquality *;

and then using the fields of this island-table within a table-box. I suspect you will then see a lot of duplication ...

asheppardwork
Contributor III
Contributor III
Author

Thank you sir, I have decided to try another approach, but I think your solution would have worked if my data were cleaner.  Again, I appreciate the help and apologies for taking so long to approve; been re-thinking my entire career, lol.