Forum Discussion

JoeNews's avatar
JoeNews
Copper Contributor
Aug 20, 2021
Solved

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?
  • PeterBartholomew1's avatar
    Aug 20, 2021

    JoeNews 

    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)
      )

Resources