#Check if more than one of a set of conditions is true

1 messages · Page 1 of 1 (latest)

full elbow
#

Say I have 3 conditions that I want to check as a group: A, B and C

I want a condition that checks if more than one of them are true. Not all must be true, but at least 2 have to be true.

How can I do this in a simple way?

stuck meadow
#

the quick and dirty way ... ( A and B) or (A and C) or (B and C )

#

or a logic where you count all conditions (one by one) . then check if counter >= 2.

dense magnet
#

you could template it with something like:

count = 0
output = false
if condition A then count = count + 1
if condition B then count = count + 1
if condition C then count = count + 1
if count >= 2 then output = true
return output

obviously need to write it actual template format but that maybe gives you the idea?