Asubaba
Asubaba

Reputation: 225

How to do an If Else in google sheets?

Right now I'm trying to figure out whether a cell contains one of two values, it will then perform an operation which depends on whatever value is in said cell. This is the function I have so far:

=IF(ISNUMBER(SEARCH("btc", I2)), (E2*(1+10%)-D2),""), IF((ISNUMBER(SEARCH("pp",I2)),E2-D2,""))

However I found that you cannot do 2 if statements in the same cell.

Upvotes: 19

Views: 90939

Answers (2)

user4039065
user4039065

Reputation:

Alternate with nested IFERROR functions.

=IFERROR(E2*IFERROR(SIGN(SEARCH("btc",I2))*110%,SIGN(SEARCH("pp",I2)))-D2,"")

Upvotes: 5

Scott Craner
Scott Craner

Reputation: 152450

Put your second in the false of the first instead of the "". It is called nesting:

=IF(ISNUMBER(SEARCH("btc", I2)), (E2*(1+10%)-D2),IF(ISNUMBER(SEARCH("pp",I2)),E2-D2,""))

Upvotes: 31

Related Questions