Question

Given a set of multi-dimensional data represented in a Google Spreadsheet:

 A | 1 | x
 A | 2 | y
 A | 3 | z

It is pretty straightforward to do a lookup on multiple values using the FILTER and INDEX functions. Doing a lookup for A2 would result in y. However, if the similar data is merged into a single cell:

   | 1 | x
 A | 2 | y
   | 3 | z

Is there a function that would accomplish the same thing? the FILTER method only returns the first row in the implicit set because there is only an A actually on the first row.

If interested, you can view the live sheet here using the 'Rules' sheet.

I have been working on a custom function, but am hoping for something more portable. Helper cells would be fine, as long as I can hide them on a separate sheet.

Was it helpful?

Solution

One option, using the helper cells idea, would be to "normalise" your Rules sheet on a separate (hidden) sheet, and perform lookups on that sheet. Eg, in A3 of that sheet:

=ArrayFormula(HLOOKUP(IF(ROW(Rules!A3:A),Rules!A2),Rules!A2:A,VLOOKUP(ROW(Rules!A3:A),FILTER(ROW(Rules!A3:A),LEN(Rules!A3:A)),1)-1,0))

and fill that formula across to the right as far as required. Note: this formula will only work on the new version of Sheets (which you are using).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top