You can use a combination of CHAR(MATCH...))
and Query
formula to get this
=QUERY('Sheet Name'!A1:G20,"SELECT A, B, "&CHAR(MATCH("Log 4",'Sheet Name'!A1:G1)+64)&" WHERE B='w'")
Above formula only works till column Z, but thanks to Kishkin's comment below, you can use it beyond Z like this:
=QUERY('Sheet Name'!A1:G20,"SELECT A, B, `" & =REGEXEXTRACT(ADDRESS(1, MATCH("Log 4",'Sheet Name'!A1:G1), 4), "\D+") & "` WHERE B='w'")
You use SUBSTITUTE
instead of REGEXTRACT
too. You can refer to this Question.
- the CHAR(MATCH...)) gets the column name of the desired Log
- you can then use the column name to include that column in Query
select
statement
In the MATCH
formula, you can also dynamically Match for a cell reference instead of specifying "Log 4" manually
Note: This is basically splitting the Query formula and concatenating it with another formula. So the &
, '
and "
symbols are really important
Sample Screenshot:
