Need help with nested if statements using match

tonyg88

New Member
Joined
Jan 18, 2015
Messages
12
Hi All,

Struggling with an excel problem. I have one list (list 1) with IDs and a corresponding value (letter).

Separately, i have a list of IDs (list 2) that I want to put the latest value for (see output columns for what i mean). I want to check first if a 2 -C exists, if not, check if a 2-B exists, whichever is the latest, display that value for the '2' ID.

Here's how i tackled it in excel:
  1. created a column for concatenated values for list 1
  2. Wrote nested if statement in output column of list 2
  3. nested if statement:
    1. =IF(MATCH(CONCATENATE(D1,", ","C"),C;C,0),"C",
    2. IF(MATCH(CONCATENATE(D1,", ","B"),C;C,0),"B",
      IF(MATCH(CONCATENATE(D1,", ","A"),C:C,0),"A",0)))


      Error: the formula returns a #N/A value

Note - I simplified the below example for readability, the real problem has more complicated IDs and the letter column has more characters.

List 1:

ID

<tbody>
</tbody>
Letter
concatenate (Column C)

<tbody>
</tbody>
1A1, A
1B1, B
1C1, C
2A2, A
2A2, A
2B2, B
2B2, B
2B2, B

<tbody>
</tbody>

List 2:

ID (column D)Output
1C
1C
2B
2B

<tbody>
</tbody>
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi,

Does this do what you need, if it does, your Column C is Not needed:


Book1
ABCDE
1List 1:List 2:
2
3IDLetterconcatenate (Column C)ID (column D)Output
41A1, A1C
51B1, B1C
61C1, C2B
72A2, A2B
82A2, A
911B2, B
102B2, B
112B2, B
12
13^^ Not needed
Sheet401
Cell Formulas
RangeFormula
E4=LOOKUP(2,1/FIND(" "&D4&" "," "&A$4:A$11&" "),B$4:B$11)


Formula copied down.
 
Upvote 0
thanks! seems to work, but confused how it works. What is the purpose of the "2,1" in the lookup function? also, what is the purpose of the "" and & symbols?

Also, the original list is a lot longer and has more IDs / letters, do you think the formula would still apply?
 
Last edited:
Upvote 0
We're looking up the Value of 2 within the FIND results divided by 1 (which will Never be greater than 1), so the LOOKUP will return the Last found Value (which is what you want).
The SPACE " " in front and behind the Lookup Value and Lookup Array prevents Errors for the Lookup, see my sample Row # 9, which is 11 (eleven), Not 1 (One), without the SPACES, the LOOKUP will return the incorrect result of "B".

Don't see your actual data, can not answer definitively, but it should work.
 
Upvote 0

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,038
Latest member
apwr

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