Help

Re: Random number functions

Solved
Jump to Solution
4814 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Daniel_Robbins
6 - Interface Innovator
6 - Interface Innovator

Perhaps I’m missing it, but how do I generate random numbers? I am missing “randbetween” and “rnd” from Excel.
Thanks for any and all help.

39 Replies 39
bonagres_sialla
4 - Data Explorer
4 - Data Explorer

You can Try using function like this : RIGHT(RECORD_ID(),5)

Since this thread is still seeing traffic, I should add a link to this recent post, which outlines some ways to generate unique, random[ish] values.

Adam_Lockwood
5 - Automation Enthusiast
5 - Automation Enthusiast

I’ve got a similar issue I’m trying to resolve. I would like to be able to pull text entries from another table by LOOKUP or ROLLUP and then randomize the order of those entries, i.e. not alphabetical. Here is the use-case:

We have an episode table, a show table, and a sponsor table. Each show record is first pulling sponsor data from the sponsor table, each episode record is then pulling the aggregated sponsor data from the show table.

Episode 123 - of - Show ABC - has - Sponsor X, Sponsor Y, and Sponsor Z

I would like each new episode record to randomly order the sponsors as it is created. For example:

  • Episode 123 - Show ABC - Sponsor Y, Sponsor X, Sponsor Z
  • Episode 124 - Show ABC - Sponsor Z, Sponsor Y, Sponsor X
  • Episode 125 - Show ABC - Sponsor X, Sponsor Z, Sponsor Y

I’m also utilizing Zapier for some other automation tasks, but haven’t found a great solution there either. Any feedback/help would be greatly appreciated. Thank you!

You actually may have a useful randomizing tool there in the Code by Zapier app. You (or someone you know/hire) could write a quick bit of code that randomizes the sponsor assignment for a later step to apply in Airtable.

Jonathan_Southg
4 - Data Explorer
4 - Data Explorer

This is my first post, so forgive me if this isn’t helpful. But a workaround I use for generating random numbers is to set up the key column with this formula:

DATETIME_FORMAT(CREATED_TIME(),‘mmsss’)

It pulls the current minute and second the entry was created and displays a set of random digits. This has worked pretty well for my purposes!

Doesn’t work for me as most of my items are essentially created at the same time :frowning:

image.png

@Daniel_Robbins @Jonathan_Southgate Instead of trying to build the number manually by combining minutes and seconds, you could try using the “x” format specifier, which is a UNIX timestamp that includes milliseconds. Depending on how quickly the records are made (mainly in your case, @Daniel_Robbins), that might do the trick.

You can use the Batch Update Block to generate random numbers for your records. See screenshot below.

Interestingly, the same block can also be used to generate random names & email addresses!

Screen Shot 2020-05-19 at 11.04.19 AM

Mahmoud_Habib
5 - Automation Enthusiast
5 - Automation Enthusiast

Here’s a way to generate random number using formula field in airtable
first choose a MIN and MAX range for your random numbers then use the following formula:
image
(VALUE(DATETIME_FORMAT(CREATED_TIME(), ‘0.smh’))*(MAX-MIN))+MIN
this generates the following:
image

Moe
10 - Mercury
10 - Mercury

We’ve built an extension that allows you to generate a random number or ID. You can choose how many characters it should have and whether to include letters or not.

generate a random number