Converting Formulas

Copper Contributor

I was wondering how to convert this VLOOKUP formula =VLOOKUP(J3,$O$4:$R$12,IF(B3=“u”,2,IF(B3=“g”,3,4)),TRUE) into an INDEX MATCH formula 

2 Replies

There are several options ranging from:
=INDEX(INDEX($O$4:$R$12,,IF(B3=“u”,2,IF(B3=“g”,3,4))),MATCH(J3,$O$4:$O$12,1))
to using new functions like XLOOKUP instead (which is more efficient and gives more options)
=XLOOKUP(J3, $O$4:$O$12, CHOOSECOLS($O$4:$R$12,SWITCH(B3,“u”,2,“g”,3,4)),"not found",-1,2)

 

note many variations in between are possible using SWITCH (or IFS) instead of cascading IF, using INDEX vs CHOOSECOLS or a number of other new functions like FILTER.  But not know exactly what you are doing/need and what system you are running it is hard to recommend 1 way vs another.

If it has to be index/match, then you could also try:
=INDEX($P$4:$R$12, MATCH(J3, $O$4:$O$12), IFNA(MATCH(B3, {"u","g"}, 0), 3))

The only caveat is that if is possible someone might insert a column in between columns P and R, then will it still return the desired result (because your column reference is based on position and your columns could get shifted over).

If you want the return value to be unaffected by inserting columns, then you could try (note two commas before IFNA function):
=INDEX(($P$4:$P$12, $Q$4:$Q$12, $R$4:$R$12), MATCH(J3, $O$4:$O$12), , IFNA(MATCH(B3, {"u","g"}, 0), 3))