Forum Discussion
JoeNews
Aug 20, 2021Copper Contributor
UNIQUE function not as expected
Trying to generate an 11x4 array of unique integers. UNIQUE(RANDBETWEEN(1,44)) will generate the array but repeats numbers. Why doesn't UNIQUE work here?
- Aug 20, 2021
A standard way of getting unique values is to generate them first and then randomise their order.
= LET( index, SEQUENCE(44), random, RANDARRAY(44), seq, SEQUENCE(11,4), sorted, SORTBY(index, random), INDEX(sorted, seq) )
PeterBartholomew1
Aug 20, 2021Silver Contributor
A standard way of getting unique values is to generate them first and then randomise their order.
= LET(
index, SEQUENCE(44),
random, RANDARRAY(44),
seq, SEQUENCE(11,4),
sorted, SORTBY(index, random),
INDEX(sorted, seq)
)
- JoeNewsAug 22, 2021Copper ContributorThank you Peter. Works beautifully.