DJPlayer
DJPlayer

Reputation: 3294

Excel If Else Formula comparing string values

First I'm no Excel formula guru..

I want to write a formula that is comparing 4 possible string values

such as: Up, Down, Left, Right

pseudocode would be say:

if a1="Up" and a2="Down" then 1.1
else if a1="Left" and a2="Right" then 1.1
else if a1="Left" and a2="Down" then .95
else if a1 = a2 then 1

I'd cover all the permutations..

Upvotes: 1

Views: 7556

Answers (2)

ChrisG
ChrisG

Reputation: 1251

I view it as 6 nested if tests

  • 4 items to test/compare
  • 6 tests emerge
  • 1x2,1x3,1x4,2x3,2x4,3x4

=IF(1=2,do this,if(1=3,do this,if(1=4,do this,if(2=3,do this,if(2=4,do this,if(3=4,do this,value if every test fails))))))

I THINK Excel has a limit of 7 nested if formulas or perhaps even formulas in general.

Upvotes: 1

Scott Solmer
Scott Solmer

Reputation: 3897

Perhaps you're looking for something like this?

=IF("Test1"="","Equal1
","")&IF("Test2"="","Equal2
","")&IF("Test3"="","Equal3
","")&IF("Test4"="","Equal4
","")

Borrowed from basically the same question on SuperUser.

Upvotes: 0

Related Questions