Forum Discussion
StidifordN
Helper III
7 years agoSwitch with &&& and ||
Can a Switch include both && and ||? Looking for a rule that looks at a the [1. ### V2] (Jan through to Dec) field and if it is 3 or 5 for all 12 fields. If any of the 12 are not 3 or 5 then re...
- 7 years ago
I think this might just be an order of operations issue I think that the logical AND is evaluated first, then the OR.
So effectively you have: condition1 || ( condition2 && condition3) || condition4
Whereas I think you want: (condition1 || condition2 ) && (condition3 || condition4)
I think adding extra brackets to force the order of operation you want might fix this:
CY Activity = SWITCH( TRUE(), ([1. Jan v2] = 3 || [1. Jan v2] = 5 ) && ([1. Feb v2] = 3 || [1. Feb v2] = 5 ) , 1, 0)
I often use extra bracket if I have multiple logical AND/OR combinations to clarify the ordering
StidifordN
Helper III
7 years ago