The rand function returns a random number between 0 and 1.
Examples
The rand function is often used to generate random integers, sometimes to select a random sampling of data. For example, to generate an integer between 1 and 100 (inclusive) you could use:
(floor(rand()*100)+1)
This expression works as follows:
Uses the rand() function to generate a random number between 0 and 1.
Multiplies by 100 to turn it into a random number between 1 and 100.
Uses the floor function to round down the random number to the nearest integer, producing a random number between 0 and 99 (inclusive).
Adds 1 to bring the random integer up to 1 to 100 (inclusive).
You could then filter your query to only include data below a certain random number.
Things to know
The rand function produces a number with 16 decimal places, such as 0.04277424614631747.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[],[],null,["# rand\n\nThe `rand` function can be used in [custom filters](/looker/docs/2512/filtering-and-limiting#custom-filters) and [table calculations](/looker/docs/2512/table-calculations) to return a random number between 0 and 1.\n\nSyntax\n------\n\n**`rand()`**\n\nThe `rand` function returns a random number between 0 and 1.\n\nExamples\n--------\n\nThe `rand` function is often used to generate random integers, sometimes to select a random sampling of data. For example, to generate an integer between 1 and 100 (inclusive) you could use: \n\n (floor(rand()*100)+1)\n\nThis expression works as follows:\n\n1. Uses the `rand()` function to generate a random number between 0 and 1.\n2. Multiplies by 100 to turn it into a random number between 1 and 100.\n3. Uses the [`floor`](/looker/docs/2512/functions-and-operators#function-floor) function to round down the random number to the nearest integer, producing a random number between 0 and 99 (inclusive).\n4. Adds 1 to bring the random integer up to 1 to 100 (inclusive).\n\nYou could then filter your query to only include data below a certain random number.\n\nThings to know\n--------------\n\nThe `rand` function produces a number with 16 decimal places, such as 0.04277424614631747."]]