List.Random

List

Returns a list of random numbers between 0 and 1, with an optional seed for reproducibility.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

List.Random(count as number, optional seed as nullable number) as list

Parameters

NameTypeRequiredDescription
countnumberYesThe number of random values to generate.
seednullable numberNoAn optional integer seed for the random number generator. Using the same seed produces the same sequence.

Return Value

listA list of count random numbers, each between 0 (inclusive) and 1 (exclusive).

Remarks

List.Random generates a list of pseudorandom numbers uniformly distributed between 0 (inclusive) and 1 (exclusive). This is useful for sampling, simulations, randomized testing, shuffling data, and adding noise.

Without a seed, List.Random is non-deterministic: each query refresh produces a different sequence of values. This means the results will change every time the query is evaluated, including between previews. If you need stable values within a session (for example, to use the same random values in multiple calculations), wrap the result in List.Buffer immediately after generating it.

With a fixed seed, the same sequence is produced on every evaluation. Use a seed when you need reproducible results for testing or documentation purposes.

To generate random integers in a range [min, max), use List.Transform(List.Random(n), each Number.RoundDown(_ * (max - min)) + min). To simulate random boolean values (coin flips), use List.Transform(List.Random(n), each _ >= 0.5).

Examples

Example 1: Generate 5 random numbers

Result
Result
1{0.347, 0.812, 0.091, 0.563, 0.724}

Example 2: Generate reproducible random numbers with a seed

Result
Result
1{0.634, 0.218, 0.879, 0.456, 0.123}

Example 3: Generate random integers between 1 and 100

let
    Randoms = List.Random(5, 1),
    Integers = List.Transform(Randoms, each Number.RoundDown(_ * 100) + 1)
in
    Integers
Applied Steps

The final output — a list of 5 random integers between 1 and 100 generated from seed 1.

Result
1{64, 22, 88, 46, 13}

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks