Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to include and exclude null values using SET Analysis

exclude_warr_SID.PNG

Requirements: count distinct ProductID for below condition

1) include only Created status

2) include only when Customer_demand is not null

3) exclude when ImportID is not null

1 Solution

Accepted Solutions
maxgro
MVP
MVP

count(distinct{<Status={created}>*<Customer_demand={"*"}>*-<ImportID={"*"}>} ProductID)

1.png

View solution in original post

12 Replies
Anonymous
Not applicable
Author

I am using the IF expression as below and it seems to be working.

Count (DISTINCT if( Status='created' and  not isnull(Customer_demand) and isnull (ImportID), ProductID))

But I would like set analysis to do this. with above statement,  i am not comfortable with isnull (ImportID) part very much, because it will include all records where ImportID is a null value. Please advise

ramoncova06
Specialist III
Specialist III

this post has a couple of examples

https://community.qlikview.com/docs/DOC-3155/version/7

I normally use nullcount

=avg({<AQ={"=nullcount(TARGET)=0"}>}TARGET)

Not applicable
Author

try like this: count(distinct{<status={"created"}, Customer_demand={*}-{},ImportID={*}-{}>} ProductID)

Anonymous
Not applicable
Author

Ramon, i did not understand avg and TARGET in your expression.

Uday, your expression did not work. this is what i got:

warr_SIDpart2.PNG

Not applicable
Author

try like this: count(distinct{<status={"created"}, Customer_demand={*}-{},ImportID={}-{*}>} ProductID)

ramoncova06
Specialist III
Specialist III

that was just an example of what I have used before, try with this expresion

count(distinct{<

status={"created"}, ProductID = {"=nullcount(Customer_demand)=0"} >

*

<status={"created"}, ProductID = {"=nullcount(ImportID)=0"} > }

ProductID)

maxgro
MVP
MVP

count(distinct{<Status={created}>*<Customer_demand={"*"}>*-<ImportID={"*"}>} ProductID)

1.png

Anonymous
Not applicable
Author

Ramon, i tried your expn; result was 0. so I added minus infront of {"=nullcount(ImportID)=0"} it gave me

warr_SID_Ramon.PNG

it is missing XYZ002. otherwise it would have been the correct ansswer. because the task is to have those records with Created status, include if Cust_demand is NOT null, include if ImportID IS null.

Anonymous
Not applicable
Author

Massimo, you nailed it. That was the answer. I have broken down the expn to understand your key.

count(distinct{<Status={created}> : this part I get it. Clear


*<Customer_demand={"*"}>* : here, by {'*'}, you mean include all non-null values for Cust_demand..?? what do ** mean at either ends..?


-<ImportID={"*"}>} ProductID) : here I understand that u r doing opposite of Cust_demand, becoz we want to count null values. but there is no ** on either sides. please explain