Reputation: 21212
I'm using an index(match()) function to return a value based on the name of a column header. However, I've recently learned that a column header can appear 4 times in my data. However, there would only ever be one populated, the others would always be empty.
Whilst I could do a nested if =(isblank(...)# do stuff)
I wondered if there was a more sophisticated way to tell GSheets to return the first non null / empty value, kind of like the SQL coalesque()
function.
Is there?
Current formula looks like this:
=index('Form Responses 1'!$A$2:$DY,match($A2,'Form Responses 1'!$A$2:$A,0),match(I$1,'Form Responses 1'!$A$1:$DY$1,0))
However, this piece is the problem piece:
match(I$1,'Form Responses 1'!$A$1:$DY$1,0)
This is because I$1 appears 4 times in range Form Responses 1'!$A$1:$DY$1
. The one that I want is the one that does not return a empty cell when nested in index()
function.
Upvotes: 2
Views: 1988
Reputation: 18707
I've made a more simple case when all the data is on single sheet.
The formula is:
=QUERY(TRANSPOSE({A1:E1;FILTER(A2:E8,A2:A8 = 2)}),
"select Col2 where Col2 is not null and Col1 = 'foo' limit 1")
2
is criteria by row ($A2
in your sample)foo
is criteria by column ( replace it with " & I$1 & "
)How it works
{A1:E1; filter }
is to get headers and desired row in one arrayTRANSPOSE
is to use querywhere Col2 is not null
is to get rid of empty cellslimit 1
is like select first 1
Upvotes: 2