Lookup specific value
I am using the formula =LOOKUP(B2-1,$B$2:B2,$C$2:C2) to lookup the value on it's parent level (I.E. level 2 lookup results value of next level 1 above). The formula doesn't work when there's duplicate values as shown below on ID 8. I am trying to get the lookup value on ID 8 to show the value on ID 7, but it's showing the value on ID 3 (which are both level 2). Is there a way to set the lookup to pull the "closest" in reference to cell location? Or any other way to get the correct value.
| ID | level | value | result from my lookup formula | expected lookup return value |
|---|---|---|---|---|
| 1 | 1 | 1 | #n/a (formula =LOOKUP(B2-1,$B$2:B2,$C$2:C2) ) | #n/a |
| 2 | 2 | 2 | 1 | 1 (value on ID 1) |
| 3 | 2 | 2 | 1 | 1 (value on ID 1) |
| 4 | 3 | 4 | 2 | 2 (value on ID 3) |
| 5 | 4 | 5 | 4 | 4 (value on ID 4) |
| 6 | 3 | 2 | 2 | 2 (value on ID 3) |
| 7 | 2 | 1 | 1 | 1 (value on ID 1) |
| 8 | 3 | 2 | 2 (want lookup value from ID 7; looking up the value from ID 3) | 1 (value on ID 7) |
| 9 | 2 | 2 | 1 | 1 (value on ID 1) |
Posted Mar 11, 2019, 8:50 PM UTC
33
There’s probably a lot of detail to get into here, but the short version is that any function performing an approximate match (which LOOKUP is only capable of doing) will probably not return any logical results over unsorted data.* Your data in B is not sorted.
Try
This also does not provide sorted data, but rather an array of 1s (where B=(B2-1)) and errors (where B<>(B2–1)) to which searching for 2 provides the last 1, so the last matching record. You’ll get a #DIV/0! instead of your N/A! for the first record; if that’s a real crisis you can IFERROR(...,errortext) the formula and provide something else.
Note: *there is, of course, a logic underneath the results provided by an approximate match over unsorted data, but it’s not something I can explain succinctly.
Solution Verified
You have awarded 1 point to finickyone
^I ^am ^a ^bot, ^please ^contact ^the ^mods ^for ^any ^questions.
[deleted]