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: 
tbgrant33
Contributor II
Contributor II

Counting nulls and not nulls

I'm trying to count 3 different statuses based on several different conditions:

  1. count if the status = 'Won' and if the date is not null
  2. count if the status is not 'Won' and if the date is not null
  3. count if the date is null

This is what I've tried so far:

  1. count({<status={'Won'}>} status) 
    1. I'm not sure how to include the condition if date is not null
  2. I could mathematically figure this one out if I somehow can count how many non-null date values there are then subtract #1 from that
  3. I know of the function isNull() and that it returns -1 or 0, but I'm unsure how to get a count from that - I've seen people set flags in the script but I failed at that.

 

 

for example:

statusdatedesired status outcome
won1/1/20201
anything but won2/1/20202
-3/1/20202
--3
won-3
anything but won-3
5 Replies
Anil_Babu_Samineni

1. count if the status = 'Won' and if the date is not null

Count({<Status={'Won'}, Date={"=Len(Date)>0"}>} Status)

2. count if the status is not 'Won' and if the date is not null

Count({<Status-={'Won'}, Date={"=Len(Date)>0"}>} Status)

3. count if the date is null

Count({<Date={"=Len(Date)=0"}>} Status)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
tbgrant33
Contributor II
Contributor II
Author

Thank  you, #1 and #2 are working! But I'm getting and output of 0 for #3

QFabian
MVP
MVP

the magic function is : isnull() :

Count(if(isnull(Date), Status))

QFabian
tbgrant33
Contributor II
Contributor II
Author

Thank you that worked!! I knew about that function but wasn't using it right apparently

Anil_Babu_Samineni

@tbgrant33  please close this thread by marking accepted solution which is worked for you

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful