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: 
ChanceyJoel
Contributor
Contributor

count if [((x or y) and (z)) or ((x or y) and (null(z)))]

Hi, I am trying to filter a pie chart using an expression to count the Product IDs where [("Program" = "Math" or "Liberal Arts") and Graduation Date >= 10/1/2022] or [("Program" = "Math" or "Liberal Arts") and Graduation Date = null] 

I have the first part of the equation:

=count({<

Program={'Math','Liberal Arts'}

, [Graduation Date]={">=$(=Date(Date#('10/1/2022','MM/DD/YYYY')))"}

>}distinct [Product ID])

I don't know how to add on the second half of the expression and the null part. Any help welcome!

Labels (3)
5 Replies
BrunPierre
Partner - Master
Partner - Master

Hi, perhaps like this.

=count({<Program={'Math','Liberal Arts'}, [Graduation Date]={">=$(=Date(Date#('10/1/2022','MM/DD/YYYY')))"}> + Program={'Math','Liberal Arts'}, [Graduation Date]={"=IsNull([Graduation Date])"}>}distinct [Product ID])

brunobertels
Master
Master

Hi 

Here below an example with OR AND in set analysis 

https://community.qlik.com/t5/New-to-Qlik-Sense/Qlik-sense-set-analysis-and-or/td-p/1337192 

ChanceyJoel
Contributor
Contributor
Author

😞 It didn't work.

I simplified the expression to this below and this part might be where the error is: 

=count({< [Graduation Date]={"=IsNull([Graduation Date])"}>}distinct [Product ID])

 

 

 

 

BrunPierre
Partner - Master
Partner - Master

[Graduation Date]= {'=Len(Trim([Graduation Date]))=0'}

 If you have a field that uniquely identifies records

ID = E({<[Graduation Date]= {"*"}>})

The best way would be to assign a value to null values in the script

If(IsNull([Graduation Date]) or Len(Trim([Graduation Date]))=0, 'NULL', [Graduation Date]) as [Graduation Date]

and then use it within the expression.

[Graduation Date]= {'NULL'}

vinieme12
Champion III
Champion III

Either of below should work

=count({< Program={'Maths','Liberal Arts'},[Graduation Date]={">=$(=Date(Date#('10/01/2022','MM/DD/YYYY')))"}>
+< Program={'Maths','Liberal Arts'}, [Graduation Date]={"=len([Graduation Date])<1"}>
} [Product Id] )

 

OR

 

=count({< Program={'Maths','Liberal Arts'}
,[Graduation Date]= p({<[Graduation Date]={">=$(=Date(Date#('10/01/2022','MM/DD/YYYY')))"}>} [Graduation Date])+p({<[Graduation Date]={"=len([Graduation Date])<1"}>} [Graduation Date])
>} [Product Id] )

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