Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Seven7
Contributor II
Contributor II

Count filtering

Is it possible to use many filters with count function but combined with an OR instead of default AND "," ?

if yes how ?

if not, is there any other fuction witch can filter data based on fields and combining many conditions with logical operators : 

and, or, not ....

2 Solutions

Accepted Solutions
agigliotti
MVP
MVP

Hi @Seven7 ,

You could use an expression as below:

COUNT(  {< onefield = condition> + < anotherfield = condition ......>} distinct[fld] )

I hope it can help.

Best Regards

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it

View solution in original post

Seven7
Contributor II
Contributor II
Author

6 Replies
Chanty4u
MVP
MVP

Not sure. can you give an example what your trying to say and expected output please?

Seven7
Contributor II
Contributor II
Author

I want to use COUNT fuction in this way :

COUNT(${<onefield=condition OR anotherfield=condition ......>} distinct[fld])

is it possible ? if not how can we use many conditions with OR operator 

it seems like the comma separator between the conditions is an explicit AND !!

agigliotti
MVP
MVP

Hi @Seven7 ,

You could use an expression as below:

COUNT(  {< onefield = condition> + < anotherfield = condition ......>} distinct[fld] )

I hope it can help.

Best Regards

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
Seven7
Contributor II
Contributor II
Author

Thank you @agigliotti   😊

duchezbr
Contributor III
Contributor III

Examples of using AND and OR in Set Analysis:

  1. count({<color = {'Red'}>}transaction_id) --  count all transaction_ids where color is 'Red'
  2. count({<color = {'Red'}, size={'L'}>}transaction_id) --count all transaction_ids where color is 'Red' AND size is 'L'
  3. count({<color = {'Red'}, size = {'S', 'XS', 'XXL'}>}transaction_id) -- count all transaction_ids where color is 'Red' AND size is {'L' OR 'XS' OR 'XXL'} (i.e., commas within an element set signify OR)

Load the dataset below and use the expressions above in a KPI to test functionality:

Table:
Load * Inline [
transaction_id, transaction_timestamp, transaction_amount, size, color
3750, 2018-08-30T19:36:12Z, 23 ,L, Red
3751, 2018-08-30T19:36:13Z, 5356.31 ,M, Orange
3752, 2018-08-30T19:36:14Z, 15.75 ,S, Blue
3753, 2018-09-16T12:30:00Z, 1251 ,L, Black
3754, 2018-09-16T13:15:30Z, 21484.21,XS,Red
3754, 2018-09-16T13:20:30Z, 21484.21,XS,Red
3754, 2018-09-16T13:35:30Z, 21484.21,XS,Red
3754, 2018-09-16T13:35:30Z, 21484.21,S, Red
3755, 2018-09-30T13:35:30Z, -59.18, M, Blue
];

Seven7
Contributor II
Contributor II
Author

Thank you @duchezbr for your reply 

but in this case (i.e., commas within an element set signify OR) the condition will be about the same expression/field ....

in my case  (where conditions are applied on differents expressions/fields) the "+" is the solution