Understanding Condition Grouping Logic

  • 2
  • Question
  • Updated 3 years ago
Here is my grouping logic:

1 AND 2 AND (3 OR (4 OR 5))

Condition 3 is a parameter condition set to deactivate if it doesn't return rows.
What I'm hoping for is that if condition 3 does return rows, conditions 4 and 5 will be ignored, but if it doesn't, conditions 4 (and if not 4, 5) will be evaluated.

Is that what I can expect to happen?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 2
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
^bump^
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Well that's not exactly correct.  4 and 5 are still be evaluated,  but depending on how you have Condition 3 set up I think you can still get the results you are looking for. 

If your condition is merely looking for the presence of the parameter,  I think it will work because no matter what values are in 4 or 5 the grouping will be true.  

However if it is looking for a specific value in the parameter you could get inconsistent results.  This is because 4 and 5 are still being evaluated and though 3 is False, the or statement with 4 and 5 still makes the entire grouping True. 

Hope this helps. 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Ok, that works. Thanks.

Two follow-up questions:
  1. Wouldn't it be slightly better from a performance standpoint to stop evaluating conditions linked by OR statements as soon as one came back true?
  2. How does Skuid handle OR conditional logic when new rows are created in a model?
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I can't answer your first question, but exploring your second one suggests that each condition prepopulates the new record with the selected value,  regardless of the condition logic.  They are all applied. 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Hmm, that's unfortunate. Ok. Thanks, Rob!