spreadsheetlibreofficecalc

How to randomly combine (concatenate) text in cellsin two columns


I want to combine text in multiple cells in one column with text in multiple cells in another column in two columns and have the combinations with permutation (the combination should have the text from first column first and second column second in the combined text/result, i.e. only ad, ae, af, bd............. and not da, ea etc.) in a third column.

X Y Z
a d ad
b e ae
c f af
bd
be
bf
cd
ce
cf

Preferably there should be no repetition.

If there is a way to randomly create the results (resulting text) in the third column such that both results (the combination can have the text from first column first and second column second in the combined text/result and also first text second from first column and second text from the first column, i.e. all combinations ad, da, ae, ea, af, fa, bd, db, ......), that would also be nice to know.

I researched online and searched the libreoffice menu. Two items combin and permut seemed promising, but documentation are lacking as to how to use them?


Solution

  • In fact, in Calc, this is very simple - you only need two steps.

    First, write down the formula of the form

    {=TEXTJOIN(CHAR(10);1;A2:A4&TRANSPOSE(B2:B4);B2:B4&TRANSPOSE(A2:A4))}
    

    (this is an array formula, complete the formula with Ctrl+Shift+Enter!)

    Now select the cell with the result of the formula and choose Data - Text to Columns from the menu.

    Cartesian product in Calc