I want to combine multiple columns in a Google sheet into one cell, including headers / labels. My input sheet looks like this:
| Name | Description | Col 1 | Col 2 | Col 3 |
|---|---|---|---|---|
| Foo | val 1 | val 2 | val 3 | |
| Bar | val x | val y | val z |
And I want to concatenate the values in each column into a single cell, including the headers for each value. Desired output:
| Name | Description |
|---|---|
| Foo | Col 1 val 1 Col 2 val 2 Col 3 val 3 |
| Bar | Col 1 val x Col 2 val y Col 3 val z |
This formula concatenates the columns into one, however it doesn't include the headers (note that char(10) produces a linebreak):
=TEXTJOIN(char(10),true,B2:E2)
I can produce a similar result using REDUCE (I can't believe I'm writing a reducer in a Google Sheet):
=REDUCE("", B2:E2, LAMBDA(accumulator, current_value, CONCATENATE(accumulator, current_value, char(10))))
However the lambda function doesn't seem to provide the index of the current iteration, so I'm not sure how to grab the column name above it.



