17. Randarray and Textjoin



 PROBLEM:  How to build a table with random values, characters or numbers?


For example: =TEXTJOIN("";1;INDEX(CHAR(SEQUENCE(26;1;65;1));RANDARRAY(4;1;1;26;TRUE)));

    This formula is a nested TEXTJOIN, INDEX, SEQUENCE, and RANDARRAY function that returns a string of two random uppercase letters from the English alphabet.



    Here’s how it works:

    It is used to count the number of times a specific value appears in a table, given certain conditions.

    Here is a breakdown of the formula:

    1.  SEQUENCE(26;1;1;1) returns an array of numbers from 1 to 26.

    2.  RANDARRAY(2;1;1;26;TRUE) returns an array of two random numbers between 1 and 26.

    3.  INDEX(...) returns an array of two letters from the English alphabet where each letter corresponds to the number in the array returned by step 2.

    4.  TEXTJOIN("";1;...) concatenates the two letters in the array returned by step 3 with no delimiter.
TEXTJOIN

Textjoin - Syntax

TEXTJOIN(delimiter, ignore_empty, text1, [text2],…)



Joins 2 random numbers from 1 to 26 delimited by "", ignoring empty values.

    
            

At our table:

TEXTJOIN("";1;INDEX(SEQUENCE(26;1;1;1);RANDARRAY(2;1;1;26;TRUE))
4 24


Joins 4 random characters from A to Z delimited by "", ignoring empty values.

                        
                

At our table:

TEXTJOIN("";1;INDEX(CHAR(SEQUENCE(26;1;65;1));RANDARRAY(4;1;1;26;TRUE)))
B J L H
SEQUENCE

Sequence - Syntax

SEQUENCE(rows, [columns], [start], [step])


When the number of rows are determined we can have a sequence.

At our table:

SEQUENCE(26;1;1)SEQUENCE(26;1;65)
165
266
367
468
569
670
771
872
973
1074
1175
1276
1377
1478
1579
1680
1781
1882
1983
2084
2185
2286
2387
2488
2589
2690
CHAR

Char - Syntax

CHAR(number)


Determines the letter behind each number. The number "65" correponds to the character "A",


                    

At our table:

CHAR(SEQUENCE(26;1;65;1))(SEQUENCE(26;1;65;1)
A65
B66
C67
D68
E69
F70
G71
H72
I73
J74
K75
L76
M77
N78
O79
P80
Q81
R82
S83
T84
U85
V86
W87
X88
Y89
Z90
RANDARRAY

Randarray - Syntax

RANDARRAY([rows],[columns],[min], [max],[whole_number])


It determines the line, from 1 to 26 (our decision) and from 65 to 90 to determine the character;

At our table:

Characters
RANDARRAY(4;1;65;90;TRUE)Matches
87V
71G
70F
68D

For numbers in our table: RANDARRAY(4;1;1;26;TRUE)

INDEX

Index - Syntax

INDEX(array, row_num, [col_num], [area_num])


Lists the 2 random numbers determined above, ignoring empty values.


                            

At our table:


From our example, above::

INDEX(SEQUENCE(26;1;1;1);RANDARRAY(2;1;1;26;TRUE))
4
24

Lists the 4 random characters determined above, ignoring empty values.


From our example, above::


                                  
INDEX(CHAR(SEQUENCE(26;1;65;1));RANDARRAY(4;1;1;26;TRUE))
B
J
L
H