Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
varunreddy
Creator III
Creator III

Count of ID's between two dates group by each date

Hi All,

I am trying to count the ID's for multiple dates where Open Date is  in between Month Start and Month End for that particular date.

Date here is the dimension.

If the Date value is April 30 2019, I need all the ID's that have Open Date from April 1 to April 30.

If the Date value is March 30 2019, I need all the ID's that have Open Date from March 1 to March 30.

If the Date value is Feb 28 2019, I need all the ID's that have Open Date from Feb 1 to Feb 28.

Expression Used:

Count({<[Open Date] = {">$(=Date(Date#(Addmonths(max(Date),-1),'MM/DD/YYYY'),'MMM DD YYYY'))<=$(=Date(Date#(max(Date),'MM/DD/YYYY'),'MMM DD YYYY'))"}>}DISTINCT ID)

I have also attached the Excel file and the QVW for the reference. 

Thanks in advance!

Expected Output:

Date                    # ID

4/30/2019          2

3/30/2019          1

2/28/2019          1

 

 

 

 

 

1 Solution

Accepted Solutions
Vegar
MVP
MVP

I have not been able to look at your files hence I'm in my mobile answering, but an alternative solution to your problem is to flag the Open Date rows that are in the month of the Date inside the script.

Load * ,
If(InMonth ([Open Date], Date, 0) ,1,0) as _OpenDateInDateMonth
from Excel

Then the expressing could be
=Count({<_OpenDateInDateMonth={1}>} distinct ID )

View solution in original post

8 Replies
varunreddy
Creator III
Creator III
Author

Attaching the QVW for reference.

 

Thanks,

Varun

PrashantSangle

Where you want to implement that logic? in Front end or in script??
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
varunreddy
Creator III
Creator III
Author

Front end. 

 

 

varunreddy
Creator III
Creator III
Author

Hi Prashanth,

Front end. I have also attached the sample QVW.

 

 

PrashantSangle

If you want it in script then create flag and used that flag in front end
try below logic

Load Date,
OpenDate,
if(Date=MontEnd(OpenDate),'1','0') as cnt_flag
ID
From TableName;

Then In Front End
Take Straight Table
Dimension > Date
Expression > Count({<cnt_flag={'1'}>}ID) or Sum({<cnt_flag={'1'}>}ID)

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
PrashantSangle

Note : Check Date Format.

if(Date=MonthEnd(OpenDate),'1','0') as cnt_flag

Regards,
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Vegar
MVP
MVP

I have not been able to look at your files hence I'm in my mobile answering, but an alternative solution to your problem is to flag the Open Date rows that are in the month of the Date inside the script.

Load * ,
If(InMonth ([Open Date], Date, 0) ,1,0) as _OpenDateInDateMonth
from Excel

Then the expressing could be
=Count({<_OpenDateInDateMonth={1}>} distinct ID )
PrashantSangle

in frontend try below expression
Count({<Date= {">$(=MonthEnd(max([Open Date])))"}>}DISTINCT ID)

Note:
careful with Date Format.

Regards,
Prashant Sangle
Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂