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: 
archire2102
Partner - Contributor III
Partner - Contributor III

Count of multiple columns with or condition in set analysis

Hi,

I am trying to get the count ID where fieldA and fieldB is not empty AND field1 is not empty OR field2 is not empty OR field3 is not empty with the below expression, but its not working:

=Count({$<fieldA =-{''},fieldB=-{''},field1 -={''}>+

<fieldA =-{''},fieldB =-{''},field2 -={''}>+

<fieldA =-{''},fieldB =-{''},field3 -={''}>} Distinct [ID] )

17 Replies
sunny_talwar

I am not asking for real confidential data.... all I am seeking is mocked up dummy data which is close to your real data and which can help us see the issue

menta
Partner - Creator II
Partner - Creator II

Can you split the expression and try it?

archire2102
Partner - Contributor III
Partner - Contributor III
Author

Hi Sunny,

Hope this helps to understand the data.

sunny_talwar

This is great, all I need know is which IDs should be counted?

sunny_talwar

Are you looking to get 13?

Capture.PNG

archire2102
Partner - Contributor III
Partner - Contributor III
Author

Yes, but there are many expressions like that so its difficult to use flag for all the expressions or is it the best way?

sunny_talwar

For when you have nulls, flags are usually the best way... but you don't really have to use it.... try this

=Count(DISTINCT {<ID = {"=(Len(Trim(FieldA)) > 0 and Len(Trim(FieldB)) > 0 and Len(Trim(Field1)) > 0) or

    (Len(Trim(FieldA)) > 0 and Len(Trim(FieldB)) > 0 and Len(Trim(Field2)) > 0) or

    (Len(Trim(FieldA)) > 0 and Len(Trim(FieldB)) > 0 and Len(Trim(Field3)) > 0)"}>} ID)

archire2102
Partner - Contributor III
Partner - Contributor III
Author

Thanks Sunny,

So the solution here is, I used IF condition in expression itself rather than Set analysis and your solution is helpful in some cases where IF condition is also not working at front end.