Hi, how to use a XOR formula with 3 and 5 arguments (with real world use cases)? I’m trying to understand how i can apply this in real life

How do you want to define XOR for multiple inputs?

- true only if an odd number of inputs is true (parity)
- true only if one of the set is true (one-hot)

## True only if an odd number of inputs is true (parity)

In this case, sum the number of true inputs, and see if the result is odd.

```
IF(
MOD(
IF(Case1, 1) + IF(Case2, 1) + IF(Case3, 1),
2
),
"true",
"false"
)
```

For five inputs, add more `IF`

functions to the sum.

```
IF(
MOD(
IF(Case1, 1) + IF(Case2, 1) + IF(Case3, 1) + IF(Case4, 1) + IF(Case5, 1),
2
),
"true",
"false"
)
```

## True only if only one of the items is true (one-hot)

Check the cases where one input is true and the rest are false.

Three inputs:

```
IF(
OR(
AND(Case1, NOT(Case2), NOT(Case3)),
AND(NOT(Case1), Case2, NOT(Case3)),
AND(NOT(Case1), NOT(Case2), Case3)
),
"true",
"false"
)
```

For five inputs, continue the pattern.

```
IF(
OR(
AND(Case1, NOT(Case2), NOT(Case3), NOT(Case4), NOT(Case5)),
AND(NOT(Case1), Case2, NOT(Case3), NOT(Case4), NOT(Case5)),
AND(NOT(Case1), NOT(Case2), Case3, NOT(Case4), NOT(Case5)),
AND(NOT(Case1), NOT(Case2), NOT(Case3), Case4, NOT(Case5)),
AND(NOT(Case1), NOT(Case2), NOT(Case3), NOT(Case4), Case5)
),
"true",
"false"
)
```

If this answers your question, please mark this post as the solution. Otherwise, could you please give a bit more details and a screen capture?

Thanks @kuovonne!

This clears up the logic of the formula

However what is a real life use case for 3 arguments and 5 arguments? I’m trying to understand when I would ever use this formula in real life.

Usually if I want to compare 3 or 5 arguments, I would want control flow over them. Eg if first argument is true, then do this for the second etc.

However XOR is like so random. So long as odd number is true then it’s true. It’s so strange (or rather I’ve never come across a real life use case)

Could you give me an example when I would use XOR? Thank you!!

Usually XOR is used when building circuits or other computations.

The one-hot meaning is most common in regular life. For example, when ordering at a restaurant, there might be a choice of multiple entrees, but you can choose only one entree.

The parity meaning in regular life is better understood in terms of a series of transactions. Suppose your order a product online, then decide to cancel the order, then decide to cancel the canceling. In that case, the two “cancels” would cancel each other out, and your original order would stand. In the “Bill and Ted Excellent Adventure” series of movies, the quote "That Was Non-Non-Non-Non-Heinous!” also uses the parity meaning. Every “non-non-” pair drops out, so an even number of “non-”'s means that the thing was heinous, but an odd number of “non-”'s means that the thing was actually good.

If this answers your question, please mark this post as the solution. Otherwise, could you please give a bit more details and a screen capture?

I just realized you were probably asking about the `XOR()`

that Airtable already has, not asking for a formula to replicate its functionality. It is difficult to remember all of the functions that Airtable has, and sometimes Airtable quietly adds new functions.

In any case, I hope that you have your answer.

Whao that’s a great explanation @kuovonne!! I’m sure anyone who was perplexed by XOR has a much better understanding of it when they read through this thread and your answer now

I think XOR is still quite an esoteric function cause it requires that the conditions are “fungible” thus negative multipled by negative multipled by negative etc gives us something meaningful.

Yea I can see in terms of switches how that would work (like sending button pushes to IoT switches) actually but in majority of real life conditional control flows would be more human useable cause each step we can define different semantics and usually each step has different semantics.

Thanks once again @kuovonne!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.