# Writing “Either Or” formula in Excel [Formula Howtos]

We all know the AND, OR & NOT formulas in Excel using which you can perform simple logical operations And, Or & Negate. But what if you are the chief of HR at ACME Company, where they have a strange rule on extra allowance like this:

**Now, to calculate the dates in a month that meet this clause, we need an “exclusive OR” formula or what geeks call as “XOR” operation. **

The logical operation … exclusive or (symbolized XOR, EOR), … results in a value of true if exactly one of the operands has a value of true. A simple way to state this is “one or the other but not both.”

Now, XOR or exclusive Or is a fairly common logical test, but there is no straight forward formula to test this. Instead we have to use a lengthy combination or AND, OR and NOT formulas to arrive at XOR.

**For eg. assuming you want TRUE only when one of the two logical conditions A or B is TRUE, **

you have to write,

`=OR(AND(NOT(A),B),AND(A,NOT(B)))`

[Afterall, that is how XOR operation is defined to begin with]

Now, that seems like an awful formula. May be there is a better formula after all?!? One that is less crazier than the HR clause of ACME Co.

Well, there is.

**If you observe closely, XOR is nothing but <> (not equal to sign).** So, instead of going nuts writing the lengthy ANDORNOT combination, you can simplify the formula to,

`=A<>B`

and it gives the same outcome.

So, the formula to find whether a given date (in cell A1) qualifies for bonus allowance,

`=IF((WEEKDAY(A1)=6)<>(MOD(DAY(A1),5)=0),"Pay Bonus","Pay Regular")`

**More about logical formulas in Excel**

AND Formula | OR Formula | NOT Formula | 51 common excel formulas

**Do you XOR in real life?**

There have been few occasions when I had to XOR in my worksheets. I found that writing the correct formula can be a bit tricky depending on how *crazy* the rule is. But almost always a combination of <>, NOT, AND and OR worked for me well.

**What about you? Do you write formulas that involve complex IF clauses?**

### Do you want to be awesome in Excel?

**Here is a smart way to become awesome in Excel**. Just signup for my Excel newsletter. Every week you will receive an Excel tip, tutorial, template or example delivered to your inbox. What more, as a joining bonus, I am giving away a 25 page eBook containing **95 Excel tips & tricks**. Please sign-up below:

Your email address is safe with us. Our policies

#### More awesome tips for you:

### Leave a Reply

Annual Goals Tracker Sheet [awesome ways to use excel] |
Exploring Profit & Loss Reports [Part 4 of 6] |

## 11 Responses to “Writing “Either Or” formula in Excel [Formula Howtos]”

What if I have to write a formula for XOR with 3 entries? By that I mean that I need a formula that receives 3 boolean inputs and returns TRUE only when only one of the inputs is also TRUE.

@Pedro.. You can use SUM formula then, like this =SUM(A,B,C)=1 to test whether only of the 3 is true.

Been there… done that

Create a long complex IF incorporating an AND or OR and then after re-looking at it, change it to incorporate a and suddenly the function is more legible, more understandable and more elegant. The poor is often overlooked.

sorry… my NOT EQUAL sign “”s did not display on my comment.

[…] Check for Either Or conditions in Excel […]

doesn’t work in a SUMPRODUCT formula. However, an XOR calculation seems to be easy enough by using ‘=1’…

Assuming A2:A6={“France”;”France”;”France”;”Other”;”Other”} and B2:B6={“France”;”Other”;”France”;”France”;”Other”} …

Not quite OR (counts all occurences of “France”):

=SUMPRODUCT(–(($A$2:$A$6=”France”)+($B$2:$B$6=”France”))

(=6)

‘Proper’ OR:

=SUMPRODUCT(–((($A$2:$A$6=”France”)+($B$2:$B$6=”France”))>0))

(=4)

XOR:

=SUMPRODUCT(–((($A$2:$A$6=”France”)+($B$2:$B$6=”France”))=1))

(=2)

Dear All,

I,ve got some difficulties to make formula in excel chart as below

conditition.

Pls see below table

1 a

2 b

3 c

4 d

5 e

6 f

. .

. .

. .

18 r

I mean, I want if I write “1” in cell A1 then in cell C1 refer to “a”.

Do you have an idea for this?

Thanks for your big help

Everyone seems so knowledgable here! I have an issue that I’ve been stuck on for the past 3 hrs trying to figure out: a formula for this:

I want cell I38 to reflect one of these two values:

If H38 reads “n” or left blank, then perform this function:multiply F38x0.1, then add F38 to that product.

If F38 is not “n” or left blank, But reads “y”, then perform this function: I38=F38

Can I even assign two functions like this (an either/or) to one cell? I’m going cross-eyed and perhaps, a little insane trying to work this. Thanks for your help!

@Bets

To solve your problem use:

=IF(OR(H38=””, H38=”n”),1.1,1)*F38

It is quite possible using the If() function to have lots of nested and totally different formulas in one cell which will do different things when the circumstances are right

Hi!

I want to know if it’s posssible for me to combine below formulas into one formula using OR.

=IF(P42<="00:45", "A", IF(P42<="01:00", "B", "C"))

OR

=IF(ISNUMBER(SEARCH("|", K42, 5)), "C", "A")

thanks!

@Adhita

Yes

But it depends on the order of the if’s and or’s

The general format is

=If( Or(Condition 1 = Value 1, Condition 2 = Value 2, Condition 3 = Value 3), Value if True, Value if False)

The Or means that it will be true of any of the 3 conditions are met

If you need them all to be True to trigger the If, use And()

=If( And(Condition 1 = Value 1, Condition 2 = Value 2, Condition 3 = Value 3), Value if True, Value if False)

You can nest results as you have done above as well

Can you post a table of what should happen if various combinations of results are met?