Reputation: 143
I am interested in creating a string of headers for a rows based on which columns are marked true (sample spreadsheet linked below)
The following formulas both return the desired result for Row 2:
=JOIN(", ",QUERY(TRANSPOSE($B$1:$G),"select Col1 where Col2 = TRUE",0))
=JOIN(", ",FILTER($B$1:$G$1,B2:G2=TRUE))
I am unable to successfully use an ARRAYFORMULA with either option. Both require the current row to be selected: QUERY in "where Col#" of query syntax and FILTER in the range for the condition syntax.
=ArrayFormula(IF(A2:A<>"",JOIN(", ",QUERY(TRANSPOSE($B$1:$G),"select Col1 where Col"&ROW(A2:A)&" = TRUE",0)),""))
=ArrayFormula(IF(A2:A<>"",(JOIN(", ",FILTER($B$1:$G$1,B2:G2=TRUE))),""))
The linked sheet below shows the desired result in COLUMN H & COLUMN J (these were updated individually. The ARRAYFORMULA options are in COLUMN I & COLUMN K (currently not working).
I am interested in a solution that can populate the desired results without requiring each row to be updated individually.
link directly to "headers" tab: https://docs.google.com/spreadsheets/d/1E7EGjK-YuVBxgdX5URnzZMDOwvF6oAi7ZJxY9HmySNc/edit#gid=966778061
Upvotes: 0
Views: 303
Reputation: 27282
In H2 try
=ArrayFormula(if(len(A2:A), regexreplace(trim(transpose(query(transpose(if(B2:G, B1:G1&", ",)),,rows(A2:A)))), ",$",),))
and see if that works?
Upvotes: 1