Search code examples
google-sheetsgoogle-sheets-formula

Merge two columns result from FILTER


In Google Sheet I have a sheet similar to this:

   A    B   C
   -    -   -
1  A    I   1
2  B    J   0
3  C    K   0
4  D    L   1
5  E    M   1
6  F    N   0
7  G    O   0
8  H    P   1

I want to filter this table based on column C, if the value is 1 include that row, otherwise excluded it.

Since VLOOKUP can't look on the left I've used this formula to obtain the following result

=FILTER(A1:B8, C1:C8=1)

E   F
-   -
A   I
D   L
E   M
H   P

So far so good. Now I wanted this result (the two columns E and F) to be merged into a single column, that is, the result I want should be this:

E 
-----   
A - I
D - L
E - M
H - P

What I have tried so far:

=TEXTJOIN(" - ", TRUE, FILTER(A1:B8, C1:C8=1))

but it gives me back this result:

A - I - D - L - E - M - H - P

or

=TRANSPOSE(QUERY(TRANSPOSE(FILTER(A1:B8, C1:C8=1)),, 9^9))

that produces the results I ALMOST want, that is, the result in a single column (good) but I can't add the hyphen symbol:

J
-----
A I
D L
E M
H P

Link to the example sheet

Any suggestion on how to "merge" the two columns from the FILTER result?


Solution

  • You may try this in Sheets:

    =FILTER(A:A&" - "&B:B,C:C=1)