Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to exclude certain value of a field in an expression

Hey guys,

I would like to you how to exclude certain value of a field in an expression. For example, I would like to count the number of userid, but without counting the value 0?

Regards and many thanks!

9 Replies
Not applicable
Author

You can try like this:

count({$<userid -= {0}>} distinct userid)

israrkhan
Specialist II
Specialist II

you can write set analysis.

1) count( {$<userid = {“*”} – {0} >} UserID ), this will count all userid, except userid =0

2) count({< userid -= {“0”}>}), this will do the same as above.

3) if you want to exclude many value, you can try like below:

count({< userid = {“*”}>} – {0, 11, 23} >} UserID), this will count all userid except userid = 0, 11, 23.

4) count({< userid -= {“0, 11, 23”}>} >} UserID). same as number 3..

Hope it helps.

and read the set analysis in the help, F1 for help... 🙂

Not applicable
Author

If I have another condition to add for UserID, say, {"=only(department)='sales'"} , how can I add two at the same time?

Not applicable
Author

count({$<userid -= {0}, department = {'sales'}>} distinct userid)

israrkhan
Specialist II
Specialist II

simply use the comma to separate the conditions, like below

=count({< userid -= {“0, 11, 23”} , department = {Sale}>} >} UserID)

Not applicable
Author

why you have two >} here? I have tried both, it seems to me there are some errors, did not work

Not applicable
Author

Hi IsrarKhan,

Just to note that there's a typo as you're enclosing the numbers 0, 11 and 23 within double quotes.

In this case they'll all be considered as one value, and not be treated as separate values to be excluded.

israrkhan
Specialist II
Specialist II

🙂 accepted, syntax mistake, as used to copy past....

but you got the idea and offcourse i think you can correct the syntax.

=count({< userid -= {0, 11, 23} , department = {'Sale'}>} UserID)    .. correct syntax.




EDIT:

and it depends , your value 0, 11 , 23 are number are strings, if numbers than it will work,

if they are strings then you need to use ' ' around each value, like


'0' , '11', '23' ...


SunilChauhan
Champion
Champion

count(distinct if(filedname<>0, UserID)

or

count(distinct if(UserID<>0, UserID)

or

count({$<UserID-= {'0'}>} distinct UserID)


hope this helps

Sunil Chauhan