• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Logical AND and OR with IF condition ..

Analyst_Kumar

New Member
Is it not possible to use AND / OR with IF condition?

I have a spreadsheet with following data.
Column A has city names such as Delhi, Mumbai, Chennai, Bangalore and Hyderabad.
For column B, I want to set value
to 2 if column A has either Chennai or Bangalore,
to 5 if column A has either Delhi or Mumbai
to 6 if column A has Hyderabad
to 0 if column A has any other value.

I use, If(A2="Chennai" or A2="Bangalore", 2, 99) It is throwing error
 
Hi Kumar,

Try the following:

=IF(A2=0,"any other value",IF(A2="Hyderabad",6,IF(OR(A2={"Chennai","Bangalore"}),2,IF(OR(A2={"Delhi","Mumbai"}),5,"Not specified"))))

Regards,
 
Or may be with lookup:

=IF(A2=0,"any other value",LOOKUP(A2,{"Bangalore","Chennai","Delhi","Hyderabad","Mumbai"},{2,2,5,6,5}))

Regards,
 
Back
Top