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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need help to build an expression

Hello,

I need to count the number of distinct Order where Status<>'X' AND Quantity<>0.

There is the expression:

=count({<Status-={'X'} AND Quantity-={'0'}>}  DISTINCT Order)

But unfortunately this syntax doesn't work, you can't put an 'AND' there...

I really dunno how to do this in a different way...

May some experts help me for this please?


Thanks,

Best Regards,

Loïc

1 Solution

Accepted Solutions
manojkulkarni
Partner - Specialist II
Partner - Specialist II

count(distinct if(Status<>'X' and Quantity<>0,Order))

View solution in original post

14 Replies
swuehl
MVP
MVP

Mayb try

=count({<Status-={'X'}, Quantity-={'0'}>}  DISTINCT Order)

Not applicable
Author

Your expression exclude all the Status='X' and all Quantity='0'.

But I want to exclude only the lines where Status='X' and Quantity='0'.

manojkulkarni
Partner - Specialist II
Partner - Specialist II

count(distinct if(Status<>'X' and Quantity<>0,Order))

paolocamerini
Partner - Contributor III
Partner - Contributor III

I'd rather use

=count({<Status={'*'}-{'X'},Quantity={'*'}-{0}>}DISTINCT Order)


Tell us if it works

swuehl
MVP
MVP

You are right.

If you need to check on a per record base, you would need to use a key field that is unique for every combination of Status and Quantity per Order in the set analysis set modifier, or use the COUNT(IF(...) ) as ManojK has shown.

effinty2112
Master
Master

Swuehl's suggestion =count({<Status-={'X'}, Quantity-={'0'}>}  DISTINCT Order) looks good to me.

It's well worth it, when you are ready to tackle it, to become familiar with this very concise set analysis notation but it can be tricky until you get used to it.

<Status-={'X'}>


means recognise user selections in the Status field but remove records where Status = 'X'.

<Status=-{'X'}>

looks as if it is the same but it's not quite, note the position of '-'. is a shorthand for

<Status=*-{'X'}>

and when you think of it like this you can see that this means disregard user selections in the Status field, i.e. include all, but remove records where Status = 'X'.

Regards

Peter_Cammaert
Partner - Champion III
Partner - Champion III

How about this one?


=count({-<Status-={'X'}, Quantity-={'0'}>}  DISTINCT Order)

Not applicable
Author

I don't know why but i got the same result doing:

count(distinct if(Status<>'X' and Quantity<>0,Order))

or

count(distinct if(Status<>'X',Order))


It seems like a bug, the second argument is forgotten...

Not applicable
Author

I don't think this could work, because in reality i have other fields that must be included in the same expression...

It's more like

=count({<Date={"<=$(varDate)"}, Status-={'X'} AND Quantity-={'0'}>}  DISTINCT Order)

Where the Date value must be included and

Status and Quantity must be excluded.