简体   繁体   中英

How can I find the closest matching value ABOVE the current cell, and return a different column in that same row?

Working in google sheets, I am trying to find the closest matching value ABOVE the current cell and return a different column from that same row.

Here is a visual of what I'm trying to achieve:

这是我试图实现的目标的视觉效果。

For any row where Column A=x, just return the value in Column B to Column "Results". If Column A does not equal x, I want to return the closest (in distance) Column B value where Column A=x above the current row. The first part (where Column A=x) is simple, but I'm having trouble with the second part, where Column A <> x. I've tried various iterations of index match, vlookup, but I keep ending up with either the first or last match, rather than the closest (in distance) above.

Thank you so much!

Try LOOKUP :

=ArrayFormula(LOOKUP(1,1/($A$1:A1="x"),$B$1:B1))

在此处输入图片说明

try:

=INDEX(IF(B:B="",, VLOOKUP(ROW(B:B), IF(ISNUMBER(1*B:B), {ROW(B:B), B:B}), 2, 1)))

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM