Program Functions

Generate Random Numbers In Notion (New Function)

New Notion Function id random numbers.png

🎲 Random Formula

There’s a new function that has just been added to notion’s formula function list. The id() function! As the name suggests, it generates a random identification for a new database entry. This ID consists of random numbers and letters. Using this randomness, I created a handful of formulas to generate random numbers from 1-10, dice roll (1-6), coin flips, and more. It’s rare for Notion to release a new formula function so this is quite special!

A New Formula Function?

It looks like the id() function grabs the unique ID given to each notion page and returns it into a formula result. The possibilities are incredible!

notion-new-formula-function-id.png
 

How To Generate A Random Number

With the addition of every new database entry, and a formula property with one or more of the formulas below, a new random number or letter will appear.

 

1- … Random Number Combinations

random-numbers-notion-number-combos.png

Random Number From 1-10

round(toNumber(replaceAll(id(), "[^0-9]", "")) % 90 / 10) + 1

Random Number From 1-100

round(toNumber(replaceAll(id(), "[^0-9]", "")) % 900 / 10) + 1

Random Number From 1-6 (dice roll)

round(toNumber(replaceAll(id(), "[^0-9]", "")) % 50 / 10) + 1

 

0- … Random Number Combinations

Random Number From 0-9

round(toNumber(replaceAll(id(), "[^0-9]", "")) % 90 / 10)

Random Number From 0-99

round(toNumber(replaceAll(id(), "[^0-9]", "")) % 990 / 10)

 

Binary And Letter Combinations

notion-random-numbers-formula-binary.png

Random Number From 0-1

round(toNumber(replaceAll(id(), "[^0-9]", "")) % 10 / 10)

Random Number From 0-1 (Coin Flip)

if(round(toNumber(replaceAll(id(), "[^0-9]", "")) % 10 / 10) == 0, "Heads", "Tails")

Random Number From 0-1 (True/False)

if(round(toNumber(replaceAll(id(), "[^0-9]", "")) % 10 / 10) == 0, false, true)

Random Letters From A-z

 

Further Reading