Home > Net >  how to concat/merge two columns with different length?
how to concat/merge two columns with different length?

Time:11-14

I'm new to google sheet. I have a column(E) with the date and another with a session(F), I want to merge them into one column with each date & different session just like the first few rows in column C.

enter image description here

I've tried "=ArrayFormula(concat(D2:D,concat(" ",F2:F5)))" in column C but only got the first date.

CodePudding user response:

In your cell C1, try this formula:

=ArrayFormula(E1:E&" "&F1:F)

CodePudding user response:

Well you can simply do concatenate cells like this:

CONCATENATE(E1, " ", F1)

to get what you want I think.

CodePudding user response:

What you're looking for is a cartesian product. I don't have a single formula that does the entire thing for you, but I can suggest a two-step approach.

Get the cartesian product with this formula:

=ARRAYFORMULA(SPLIT(FLATTEN(E2:E9 & "|" & TRANSPOSE(F2:F5)), "|"))

This gives a pair of each date against each time in two result columns. You can then concatenate each row of them in a final result column.

CodePudding user response:

use:

=INDEX(QUERY(FLATTEN(FILTER(E2:E, E2:E<>"")&" "&
           TRANSPOSE(FILTER(F2:F, F2:F<>""))), "where not Col1 starts with ' '", ))

see: https://stackoverflow.com/a/68775825/5632629

  • Related