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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
SMiller_FL
Contributor III
Contributor III

Did date A come before date B

I have 2 date fields (DtPrimaryCareMgAssign) and (DtEnrlNotif). DtEnrlNotif may have 'NONE' listed as one of the variables which I do NOT want to count. I also have a field named [tabnm] and I only need 'new' returned. The [countall] field is a catchall field that has a 1 in every line so I can do count(countall) on different items. 

 

I want to know the count for all who had a date in DtPrimaryCareMgAssign who's date came after the date listed in  DtEnrlNotif.

 

This is what I have so far and I am getting zero. 

count({<[DtPrimaryCareMgAssign]={'>=$[DtEnrlNotif]'},tabnm={'new'},$DtEnrlNotif-={"NONE"}>}[countall])

Labels (5)
1 Solution

Accepted Solutions
vinieme12
Champion III
Champion III

I suggest you simply create a new field in your script 

,if(DtPrimaryCareMgAssign]>=[DtEnrlNotif],'After','Before') as flagfield 

and use this flagfield in set analysis like below 

count({<[flagfield ]={'After'},tabnm={'new'},DtEnrlNotif-={"NONE"}>}[countall])

 

 

the way to do it in front end would be as below, this will cause performance issues

count({<[Keyfield]={"=DtPrimaryCareMgAssign>=[DtEnrlNotif]"},tabnm={'new'},DtEnrlNotif-={"NONE"}>}[countall])

or

count({<[DtPrimaryCareMgAssign]={"=DtPrimaryCareMgAssign>=[DtEnrlNotif]"},tabnm={'new'},DtEnrlNotif-={"NONE"}>}[countall])

OR

count({<tabnm={'new'},DtEnrlNotif-={"NONE"}>}   if(DtPrimaryCareMgAssign>=DtEnrlNotif ,[countall]))

 

correction, should be double quotes

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

8 Replies
vinieme12
Champion III
Champion III

I suggest you simply create a new field in your script 

,if(DtPrimaryCareMgAssign]>=[DtEnrlNotif],'After','Before') as flagfield 

and use this flagfield in set analysis like below 

count({<[flagfield ]={'After'},tabnm={'new'},DtEnrlNotif-={"NONE"}>}[countall])

 

 

the way to do it in front end would be as below, this will cause performance issues

count({<[Keyfield]={"=DtPrimaryCareMgAssign>=[DtEnrlNotif]"},tabnm={'new'},DtEnrlNotif-={"NONE"}>}[countall])

or

count({<[DtPrimaryCareMgAssign]={"=DtPrimaryCareMgAssign>=[DtEnrlNotif]"},tabnm={'new'},DtEnrlNotif-={"NONE"}>}[countall])

OR

count({<tabnm={'new'},DtEnrlNotif-={"NONE"}>}   if(DtPrimaryCareMgAssign>=DtEnrlNotif ,[countall]))

 

correction, should be double quotes

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
SMiller_FL
Contributor III
Contributor III
Author

I am getting different counts. It returns 1028 but I believe it should be 801. Should it be distinct?

vinieme12
Champion III
Champion III

since the countall field is 1; count distinct of countall will always return 1 or 2 if countall has 1s and 0's

have you tried creating a flag field in script?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
SMiller_FL
Contributor III
Contributor III
Author

I would happily do that if I knew how. Countall is always 1 by the way, never anything else. Can you please provide the flag script you are talking about? I am learning this piece by piece. Thanks. 

vinieme12
Champion III
Champion III

,if(DtPrimaryCareMgAssign]>=[DtEnrlNotif],'After','Before') as flagfield 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
SMiller_FL
Contributor III
Contributor III
Author

I'm doing this as either a table or a KPI and the below returns an error for both in the Expression builder area. What am I doing wrong?

,if(DtPrimaryCareMgAssign]>=[DtEnrlNotif],'After','Before') as flagfield
count({<[flagfield ]={'After'},tabnm={'new'},DtEnrlNotif-={"NONE"}>}[countall])

 

vinieme12
Champion III
Champion III

You have to create a field in the load script so that it exists in your data model

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
SMiller_FL
Contributor III
Contributor III
Author

Thanks, this helped!