Index Match with multiple nested if statements

equals

New Member
Joined
Sep 22, 2017
Messages
2
Hi,
I have two tables, one with "source" data as follows:
ABCDEFGHIJK
LookupHelperHighLowGeo_LookupGeo_HighGeo_LowOtherClassDescriptionImportant
A1A111Apples & OrangesN
A2#ALT 2Apples & PearsN
A255High Apples & PearsY
A256Low Apples & PearsN
A2aA2a13Oranges & PlumsY
A2c#ALT 214Plums & PearsN
A2c15Pears & Plums HighY
A2cPears & Plums LowY
B1#GEO #GEO _ALT1Apples & PearsY
B1Apples & Pears High
B1Apples & Pears LowY
B1GEOApples & Pears HighN
B1GEOApples & Pears LowY
B1OTHER Apples & PearsN
B2B26Oranges & PearsY
B2a9Kiwi & LimeN
B3#GEO #GEO _ALT#ALT 11LimeN
B3Lime HighY
B3Lime LowN
B3GEO Lime HighY
B3Geo Lime LowY
.................................

<tbody>
</tbody>

And a second "results" table which I wish to write some formulae for to lookup the description based upon its Geology and Height

ABCDEFGH
UidDefinitionResolves_toDescriptionImportantGeoHeightClass
G1A1aA1A50
G2B3#GEO 11
G3A2aA2aB2
G4A2#ALT A200
G5B2bB25
G6B2B2A36

<tbody>
</tbody>
The definition code is not always contained in the lookup table, but its parent code is so I am using the following formula to check if its present and remove the trailing sub category (the trailing alpha character) if it is not:
{=IFNA(VLOOKUP(B2:B13268,Source_Lookup_Table!A:M,2,FALSE),VLOOKUP(IF(ISNUMBER(-RIGHT(B2:B13268)),B2:B13268,LEFT(B2:B13268,LEN(B2:B13268)-1)),Source_Lookup_Table!A:M,2,FALSE))}

I would like to populate the "results" table columns D, E and H with the description/importance/class of the closest category.

The helper # codes need the following logic:
#ALT
Where "Source_Lookup_Table!B:B" = "#ALT " then choose between columns C (High) and D (Low) based upon Height >=50

#ALT 2
Where "Source_Lookup_Table!B:B" = "#ALT 2" then choose between columns C (High) and D (Low) based upon Height <=10

#GEO
Where "Source_Lookup_Table!B:B = "#GEO " check if "Results_Table!F:F" (Geo column) = A
If it does - Check the altitude is >=50 and lookup column F (Geo_High) or if <50 column G (Geo_Low)
If Column F (Geo) = B then check if it exists (or its non sub category) as a separate row in column H - if NA (cannot be found) then find it in Column A and then read column H which will resolve to "#ALT " and can therefore be resolved using columns C and D as above.

This is where I am at so far (although I currently have a few more columns in my sheet) - I am using index match so I can write the formulae and then just change the column number match resolves to extract the data I need:
{=IFS((M2:M13268>=50)*(G2:G13268="#ALT "),(IFNA(INDEX(Source_Lookup_Table!C:C,MATCH(E2:E13268,Source_Lookup_Table!C:C,0)),INDEX(Source_Lookup_Table!C:C,MATCH(F2:F13268,Source_Lookup_Table!C:C,0)))),(M2:M13268<50)*(G2:G13268="#ALT "),(IFNA(INDEX(Source_Lookup_Table!D:D,MATCH(E2:E13268,Source_Lookup_Table!D:D,0)),INDEX(Source_Lookup_Table!D:D,MATCH(F2:F13268,Source_Lookup_Table!D:D,0)))),(M2:M13268<=10)*(G2:G13268="#ALT 2"),IFNA(INDEX(Source_Lookup_Table!D:D,MATCH(E2:E13268,Source_Lookup_Table!D:D,0)),INDEX(Source_Lookup_Table!D:D,MATCH(F2:F13268,Source_Lookup_Table!D:D,0))),(M2:M13268>10)*(G2:G13268="#ALT 2"),IFNA(INDEX(Source_Lookup_Table!C:C,MATCH(E2:E13268,Source_Lookup_Table!C:C,0)),INDEX(Source_Lookup_Table!C:C,MATCH(F2:F13268,Source_Lookup_Table!C:C,0))),G2:G13268="#GEO ",VLOOKUP(F2:F13268,Source_Lookup_Table!A:M,5,FALSE),TRUE,G2:G13268)}

Because I have >13200 rows I am using {array formula}. but I have discovered lots of things like AND do not work so I have tried IF((A1>3)*(B1="#GEO ")) and lots of ISNUMBER statements to keep things true of false. I have managed to get somewhere with the first two bits of logic, but it has failed again when trying to implement the ""#GEO " logic.. It is also taking a very long time to calculate on my laptop, causing excel to freeze for minutes at a time so I was hoping there might be a more efficient method?

Any guidance very gratefully received.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I meant to say, column E (geo_lookup) can have a value (i.e. A3b) or "#GEO_ALT" which is when I would like to check the altitude and resolve between Column F (Geo_High) and Column G (Geo_Low)
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top