Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
clondono
Creator III
Creator III

Count NULL values using Set-Analysis

Hi,

I'm trying to count the number of DISTINCT projects that have NULL values for a specific field. Not all projects have null values for this field and some projects might have more than one null value for the field.  I'm using this count in a straight table for a  Pivot Chart in NPrinting.  I'm getting either an "error in set modifier expression" or an invalid result.

image.jpg

This expression returns the modifier expression error:

     =Count(DISTINCT{$<isNull(TASK_NAME)>}PROJECT_ID)

This other expression gives me the count of ALL projects not only the count of projects with NULL values for the field:

     =Count(DISTINCT{$<TASK_NAME ={0}>}PROJECT_ID)

Thanks!

1 Solution

Accepted Solutions
clondono
Creator III
Creator III
Author

Thank you Sunny and Peter, both your answers pointed me in the right direction.

I created a FlagMap in my load statement and created the following expression to get the correct results:

=Count(DISTINCT{$<Flag_Map_Field = {"=NullCount(TASK_NAME)>0"}>}PROJECT_ID)

View solution in original post

8 Replies
sunny_talwar

Try this:

=Count(DISTINCT{$<TASK_NAME = {"=Len(Trim(TASK_NAME)) = 0"}>}PROJECT_ID)

clondono
Creator III
Creator III
Author

I tried your solution but it gives me the count of all projects, not only the count of projects with NULL values for the field, the same results as this:

=Count(DISTINCT{$<TASK_NAME ={0}>}PROJECT_ID)

sunny_talwar

What about this:

=Count(DISTINCT{$<TASK_NAME = {"=NullCount(TASK_NAME) > 0"}>}PROJECT_ID)

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Sunny, maybe this minor tweak could be useful:

=Count(DISTINCT{$<PROJECT_ID = {"=NullCount(TASK_NAME) > 0"}>}PROJECT_ID)

swuehl
MVP
MVP

Or maybe without set analysis

=Count(DISTINCT If(Len(Trim(TASK_NAME))=0, PROJECT_ID))

clondono
Creator III
Creator III
Author

Thank you Sunny and Peter, both your answers pointed me in the right direction.

I created a FlagMap in my load statement and created the following expression to get the correct results:

=Count(DISTINCT{$<Flag_Map_Field = {"=NullCount(TASK_NAME)>0"}>}PROJECT_ID)

clondono
Creator III
Creator III
Author

I forgot to include the sample of the mapping load:

Task_SeqMap:

Mapping LOAD

  TASK_NAME,

  0

FROM [..\QVD\01_Extract_QVD\MYQVD.QVD]

(qvd);

LOAD

     MyFields,

     ...

      ApplyMap('Task_SeqMap',TASK_NAME ,Null()) as Flag_Map_Field, //APPLIED MAPPING TO FIELD

     ...

FROM [..\QVD\01_Extract_QVD\MYQVD.QVD]

(qvd)

;  

Anonymous
Not applicable

count({<column name={'0'}>}coulmn name)