Nested IFERROR Help

Copper Contributor

I’m trying to lookup prices from a sheet using index and match.

 

I ran into problems with my initial index and match, so started by doing 3 different index and matches for the different product types, which all work:

 

Column M - Powersafe Line Source & Line Drain (500A*/800A**)

 

=IF(F2="Set of 5",INDEX(Supplier!$C$5:$I$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C2,Supplier!$C$4:$I$4,0),MATCH($M2,Supplier!$C$3,0))*5,INDEX(Supplier!$C$5:$I$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C2,Supplier!$C$4:$I$4,0),MATCH($M2,Supplier!$C$3,0)))

 

Column M - Line Drain Lug

 

=IF(F380="Set of 5",INDEX(Supplier!$K$5:$M$13,MATCH($D380,Supplier!$A$5:$A$13,0),MATCH($C380,Supplier!$K$4:$M$4,0),MATCH($M380,Supplier!$K$3,0))*5,INDEX(Supplier!$K$5:$M$13,MATCH($D380,Supplier!$A$5:$A$13,0),MATCH($C380,Supplier!$K$4:$M$4,0),MATCH($M380,Supplier!$K$3,0)))

 

Column M – Line Source Lug

 

=IF(F542="Set of 5",INDEX(Supplier!$N$5:$P$13,MATCH($D542,Supplier!$A$5:$A$13,0),MATCH($C542,Supplier!$N$4:$P$4,0),MATCH($M542,Supplier!$N$3,0))*5,INDEX(Supplier!$N$5:$P$13,MATCH($D542,Supplier!$A$5:$A$13,0),MATCH($C542,Supplier!$N$4:$P$4,0),MATCH($M542,Supplier!$N$3,0)))

 

I want to combine these formulas so that there is one formula, rather than breaking out the data into sections with different formulas. What I’m trying to achieve is to use an IFERROR function to look at the first formula, and if there’s an error look at the second formula, and then if there’s an error look at the third formula.

 

I’ve come up with this:

 

=IFERROR(IF(F2="Set of 5",INDEX(Supplier!$C$5:$I$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C2,Supplier!$C$4:$I$4,0),MATCH($M2,Supplier!$C$3,0))*5,INDEX(Supplier!$C$5:$I$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C2,Supplier!$C$4:$I$4,0),MATCH($M2,Supplier!$C$3,0))),IFERROR(IF(F2="Set of 5",INDEX(Supplier!$K$5:$M$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C2,Supplier!$K$4:$M$4,0),MATCH($M2,Supplier!$K$3,0))*5,INDEX(Supplier!$K$5:$M$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C380,Supplier!$K$4:$M$4,0),MATCH($M2,Supplier!$K$3,0))),IFERROR(IF(F2="Set of 5",INDEX(Supplier!$N$5:$P$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C2,Supplier!$N$4:$P$4,0),MATCH($M2,Supplier!$N$3,0))*5,INDEX(Supplier!$N$5:$P$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C2,Supplier!$N$4:$P$4,0),MATCH($M2,Supplier!$N$3,0))),"N/A")))

 

The data is sorted in order, i.e. rows 2-379 show the Powersafe Line Source & Line Drain (500A*/800A**), rows 380-541 show Line Drain Lug and rows 542-703 show Line Source Lug. The formula appears to working for the Powersafe Line Source & Line Drain (500A*/800A**), and the Line Source Lug, but the middle section for the Line Drain Lug is showing a lot of N/As and only working for the values which are supposed to be x 5.

 

Can anyone please help me?

 

 

3 Replies
Hello @BooBar87

I would not advise you to do so. The formulas are already complex and it may become harder and harder to figure out how things are working in the future when you have moved on to other things.

What I would favor is using "Helper Columns" where you would do intermediate lookups and calculations and then where you want the data to be you will use a formula that reference these "Helper Columns". The advantage of this approach is simpler formulas and functions that can be easily debugged. The disadvantage is that you want want to hide these columns and that might make your report a bit unprofessional.

Look at this for more details:
https://www.exceltip.com/basic-excel/what-is-an-excel-helper-column.html
https://exceljet.net/glossary/helper-column
https://www.reddit.com/r/excel/comments/14k1vr6/is_it_ever_appropriate_to_have_to_use_helper/?rdt=50...

I hope I gave you food for though.

G.

@BooBar87 

=IFERROR(

IFERROR(

IF(F2="Set of 5",INDEX(Supplier!$C$5:$I$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C2,Supplier!$C$4:$I$4,0),MATCH($M2,Supplier!$C$3,0))*5,INDEX(Supplier!$C$5:$I$13,MATCH($D2,Supplier!$A$5:$A$13,0),MATCH($C2,Supplier!$C$4:$I$4,0),MATCH($M2,Supplier!$C$3,0))),

IF(F380="Set of 5",INDEX(Supplier!$K$5:$M$13,MATCH($D380,Supplier!$A$5:$A$13,0),MATCH($C380,Supplier!$K$4:$M$4,0),MATCH($M380,Supplier!$K$3,0))*5,INDEX(Supplier!$K$5:$M$13,MATCH($D380,Supplier!$A$5:$A$13,0),MATCH($C380,Supplier!$K$4:$M$4,0),MATCH($M380,Supplier!$K$3,0)))),

IF(F542="Set of 5",INDEX(Supplier!$N$5:$P$13,MATCH($D542,Supplier!$A$5:$A$13,0),MATCH($C542,Supplier!$N$4:$P$4,0),MATCH($M542,Supplier!$N$3,0))*5,INDEX(Supplier!$N$5:$P$13,MATCH($D542,Supplier!$A$5:$A$13,0),MATCH($C542,Supplier!$N$4:$P$4,0),MATCH($M542,Supplier!$N$3,0))

)

)

@GeorgieAnne @OliverScheurich thanks for your replies, I got some advice on a different approach and the issue is now resolved!