Md. Foysal
Md. Foysal

Reputation: 103

Generate all possible combinations for 2 Columns in Google Sheets

I have a Google Spreadsheets with three columns.

I need to populate the Column C with all the possible combinations of the values in Columns A and B. Please take a look a the capture to see what I mean.

I found this following formula, but it output result not same.but i need same as image.

i am using this code:

=ArrayFormula(transpose(split(rept(concatenate(A2:A&char(9)),counta(B2:B)),char(9)))
&" "&transpose(split(concatenate(rept(B2:B&char(9),counta(A2:A))),char(9))))

Upvotes: 2

Views: 2202

Answers (1)

Tanaike
Tanaike

Reputation: 201378

Your goal:

  • You want to achieve the image in your question.

Modification points:

  • When your formula is used, how about the following modification?
    1. Replace transpose(split(rept(concatenate(A2:A&char(9)),counta(B2:B)),char(9))) and transpose(split(concatenate(rept(B2:B&char(9),counta(A2:A))),char(9))).
    2. Replace A and B.

Modified formula:

=ArrayFormula(transpose(split(concatenate(rept(A2:A&char(9),counta(B2:B))),char(9)))&" "&transpose(split(rept(concatenate(B2:B&char(9)),counta(A2:A)),char(9))))

Result:

In this sample, above formula is put to the cell C2.

enter image description here

Upvotes: 1

Related Questions