Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
User | DISTINCT SessionIDs | AB | BC | CD | Count(DISTINCT if(AB = 'yes' and BC='yes' or CD='yes', SessionID, Null()) |
John | 206 | 76 | 37 | 9 | - |
Andy | 1 | 0 | 0 | 0 | - |
Chris | 118 | 17 | 11 | 8 | - |
Alex | 244 | 40 | 36 | 0 | - |
Peter | 200 | 11 | 15 | 15 | - |
Matt | 228 | 16 | 19 | 12 | - |
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!
Start by putting parentheses around ( BC='yes' or CD='yes' ). Usually an OR has lower order of precedence.
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
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
=count(DISTINCT {$ <AB={yes}>*(<BC={yes}>+<CD={yes}>)} SessionID)