Search code examples
if-statementgoogle-sheetssumnested-ififs

Getting #ERROR! Message when combining valid formulas


I am trying to setup a formula in one line that will calculate the proper date that a contract can be cancelled based on the Texas Addendum for Property Subject to Mandatory Owner's Association. Depending on 3 possible selections, Section A1, Section A2, or Section A3, the calculations for the possible termination of a contract vary. My formula's work on their own, but not when combined into one long if statement.

Here are the 3 formula's. All work properly on their own.

=if(E12="A1",if(B17="",B20,B17+3),)
=if(E12="A2",if(B17="","",B17+3),)
=if(E12="A3",if(B17="",B20,""),)

However, when combined into one statement I get an #ERROR!. I've tried multiple ways to write the formula but all get the same #ERROR!.

=if((E12="A2",if(B17="","",B17+3)),if(e12="A1",if(B17="",B20,B17+3)),if(E12="A3",if(B17="",B20,"")),)
=if((E12="A2",if(B17="","",B17+3)),if(e12="A1",if(B17="",B20,B17+3)),if(E12="A3",if(B17="",B20,""),))
=if((E12="A2",if(B17="","",B17+3),),if(e12="A1",if(B17="",B20,B17+3),),if(E12="A3",if(B17="",B20,""),))

Currently this is working as is as I have a final calculation in the necessary cell that takes the one value greater than zero.

=if(D31>0,D31,if(D32>0,D32,if(D33>0,D33)))

But it's not as clean as I'd like to have it. I'd prefer to have this as one single line calculation instead of in 4 different cells.


Solution

  • proper nesting is done like this:

    =IF(E12="A1", IF(B17="", B20, B17+3),
     IF(E12="A2", IF(B17="",, B17+3),
     IF(E12="A3", IF(B17="", B20, ), )))