Jan 19, 2017 07:09 AM
Is there a way to sort the records randomly (not alphabetically)? Say I have a table of students and I want them to be randomly ordered for a presentation or something?
May 22, 2023 10:27 PM
You can never achieve true randomness natively with a formula but here is what I use:
MOD(
(FIND("0", RECORD_ID()) * 11.5 + FIND("1", RECORD_ID()) * 23.21 +
FIND("2", RECORD_ID()) * 37.12 + FIND("3", RECORD_ID()) * 49.49 +
FIND("4", RECORD_ID()) * 59.89 + FIND("5", RECORD_ID()) * 67.52 +
FIND("6", RECORD_ID()) * 73.96 + FIND("7", RECORD_ID()) * 89 +
FIND("8", RECORD_ID()) * 97.54 + FIND("9", RECORD_ID()) * 101.14 +
VALUE(DATETIME_FORMAT(CREATED_TIME(), 'MMDDHHmmssSSS')) * 13.89 +
VALUE(DATETIME_FORMAT(LAST_MODIFIED_TIME(), 'MMDDHHmmssSSS')) * 17.25),
1000000
) + 1
The output is a random number (only a dozen duplicates amongst a list of 10k records in my testings).
I then sort by that column and voilà.
Jan 19, 2024 08:36 AM
This is a clever solution. Thanks for sharing. Unfortunately, my use case requires the field to be randomized upon each page load, rather than one time and then it becomes static.