XOR, NOR and NAND for complex conditions

Hello hello!

Today we have an update for those of you who have crafted custom complex conditions or those of you who would like to get started and that find AND and OR not sufficient as operators. Today we are introducing: XOR, NOR and NAND!

Before I go any further, some of you might be wondering where NOT is. We haven’t implemented it this time, as it requires some very careful changes in Apilio, but rest assured that now that we’ve implemented these other 3 operators we have a better idea of how to proceed with NOT. I can’t say anything else at this point :zipper_mouth_face:

How the logic operator XOR works

This has been implemented following Microsoft’s specification for XOR: https://support.microsoft.com/en-us/office/xor-function-1548d4c2-5e47-4f77-9a92-0533bba14f37

The operator XOR:

  • results in TRUE when the number of TRUE conditions is odd
  • results in FALSE when the number of TRUE conditions is even

So if you have three conditions (odd number) and all of them are true, XOR returns true. But if you only have two conditions (even number), then XOR returns false.

How the logic operator NOR works

NOR results in TRUE if all the conditions are false.

NOR(i_m_home, robin_is_home) returns true when nobody is at home.

NOR is just the opposite of the basic operator OR:

NOR() = NOT(OR())

How the logic operator NAND works

NAND results in TRUE if, and only if, at least one of the conditions is false.

NAND(watered_yesterday, rain_yesterday) will be true if either:

  • the plants were watered yesterday and it didn’t rain
  • it rained but the plant’s didn’t get watered

NAND is just the opposite of the basic operator AND:


But I really want the NOT operator

Good news is NOR and NAND work exactly like NOT() if only used with one element. So if you apply NOR to one condition, you’ll get the opposite, making these equivalent to NOT.

How to implement complex conditions

If you are just getting started, you want to have a look at the basic AND and OR operators in this previous article:

This article walks you through nested complex conditions, how to write them and gives you a couple of interesting examples.

I have questions! Doubts! Concerns! Requests!

Please put them below, we are happy to help! :smiley:


Hi @Anna,

Many thanks for this, much appreciated.

However, the more that people make use of complex conditions, the more likely they are to get into the situation where one of the variables happens to get renamed. This is a problem, as currently when this happens the complex condition string does not get updated to reflect the new name, which results in the condition no longer working as intended.

It would be great if you could remedy this sometime soon. :smiley:


OK, so I asked for NOT operator two days ago, and now we have it (indirectly through NAND).

Should I have asked for it sooner? :smiley: