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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Multiple conditions // Error

Hi Community,

Quick question: I am stuck with below example.

Eg. John has 206 saved sessions with 76 ABs (Value='yes') and another 37 with BCs and another 9 CDs.

I am trying to get the number of distinct sessions with ABs and (BCs or CDs).

When I put the formula as below, it does not give me a result.

      

UserDISTINCT SessionIDsABBCCDCount(DISTINCT if(AB = 'yes' and BC='yes' or CD='yes', SessionID, Null())
John20676379-
Andy1000-
Chris11817118-
Alex24440360-
Peter200111515-
Matt228161912-

I would highly appreciate if someone could help me out. Is there a syntax error or a problem with the "and" / "or" usage?

Many thanks in advance!

4 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Start by putting parentheses around ( BC='yes' or CD='yes' ). Usually an OR has lower order of precedence.

datanibbler
Champion
Champion

Hi,

you must take care of your brackets.

In your example, you should put it like >> IF(AB = 'yes' AND (BC = 'yes' or CD = 'yes') <<

=> That will count the records where

     - AB is true

     - AND (either BC or CD) is true

HTH

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Is this an example of what you're trying to accomplish ?

Note that a complex datamodel (i.e. one where fields are located in different tables) may provide poor performance or fail to produce correct results..

Peter

maxgro
MVP
MVP

=count(DISTINCT {$ <AB={yes}>*(<BC={yes}>+<CD={yes}>)} SessionID)