Home > Enterprise >  Combine 3 IF statements into one line (w/Index-Match)
Combine 3 IF statements into one line (w/Index-Match)

Time:02-23

I'm looking to have all 3 formulas combined into one single line. I'm having a hard time simplifying this without getting an error:

=IF(C2="Products", IFERROR(INDEX('MMA Product List'!$A:$A,MATCH(E2, 'MMA Product List'!$B:$B,0)), "Not Found"), "Not Found")
=IF(C2="MenuCategory", IFERROR(INDEX('Products Category List'!$B:$B,MATCH(E2, 'Products Category List'!$A:$A,0)), "Not Found"), "Not Found")
=IF(C2="Ingredient", IFERROR(INDEX('Ingredients List'!$A:$A,MATCH(E2, 'Ingredients List'!$B:$B,0)), "Not Found"), "Not Found")

I thought I could just separate each with a comma in one line, but it won't let me do that.

Thanks!

CodePudding user response:

You'll need to "nest" these if formulas, so that the third parameter instead of being "Not Found" is the next If formula. Something like:

=IF(C2="Products", IFERROR(INDEX('MMA Product List'!$A:$A,MATCH(E2, 'MMA Product List'!$B:$B,0)), "Not Found"), IF(C2="MenuCategory", IFERROR(INDEX('Products Category List'!$B:$B,MATCH(E2, 'Products Category List'!$A:$A,0)), "Not Found"), IF(C2="Ingredient", IFERROR(INDEX('Ingredients List'!$A:$A,MATCH(E2, 'Ingredients List'!$B:$B,0)), "Not Found"), "Not Found")))
  • Related