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

Count using Set Analysis

Col A IDSourceTargetColB ID
148Sys ASys KC1
141Sys BSys KC1
130Sys CSys KC1
121 Sys KC1

 

I'll use the above table to illustrate an issue I'm having. 
I want to create a set analysis to find 'Distinct Col ID' if 'Source' is null and 'Target' is not. ( for example , COL A ID 121 in this case)
This is a measure field that is used at the row level in the pivot table.

I created set analysis using the below options and it gives incorrect result.

1)count({<[Target]-={""} distinct Col A ID) - count({<[source]-={""},[Target]-={""}>} distinct Col A ID) 

2) count({<[source]={""},[Target]-={""}>} distinct Col A ID)

what am I doing wrong here?

 

 

 

Labels (1)
2 Solutions

Accepted Solutions
OmarBenSalem

null values are not always defined by "field={""}", for me the best way to find null values in set analysis would be like this :

 count({<[source]={"=len(trim(source))=0"},[Target]={"=len(trim(Target))<>0"}>} distinct Col A ID)

View solution in original post

PPAT1981
Contributor II
Contributor II
Author

 Thanks, It's an interesting way to count null values. In my case, only the below expression calculates the value. However, I will examine the underlying data to determine a problem.

count({<[Target]-={""} distinct Col A ID) - count({<[source]-={""},[Target]-={""}>} distinct Col A ID) 

Thank you !!

View solution in original post

5 Replies
GaryGiles
Specialist
Specialist

The second expression works, with a slight change to the field name and using []:

count({<[Source]={""},[Target]-={""}>} distinct [Col A ID])

Not sure if that is the issue you were having.  I the expression above does not work, you may want to check to see that Source is actually getting populated with Null values.

OmarBenSalem

null values are not always defined by "field={""}", for me the best way to find null values in set analysis would be like this :

 count({<[source]={"=len(trim(source))=0"},[Target]={"=len(trim(Target))<>0"}>} distinct Col A ID)

PPAT1981
Contributor II
Contributor II
Author

Thanks but not sure why this doesn't work,  maybe because this is one of the many measures in the pivot table.

OmarBenSalem

can you attach a picture of what you have to see the input and its result?

PPAT1981
Contributor II
Contributor II
Author

 Thanks, It's an interesting way to count null values. In my case, only the below expression calculates the value. However, I will examine the underlying data to determine a problem.

count({<[Target]-={""} distinct Col A ID) - count({<[source]-={""},[Target]-={""}>} distinct Col A ID) 

Thank you !!