Number.Random

Number

Returns a random number between 0 (inclusive) and 1 (exclusive). The value changes on each call.

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

Syntax

Number.Random() as number

Return Value

numberA pseudo-random number in the range [0, 1).

Remarks

Number.Random returns a pseudo-random floating-point number uniformly distributed in the interval [0, 1) — meaning 0 is possible but 1 is not. The function takes no arguments.

Non-determinism warning: Number.Random produces a different value on every call and on every refresh. This means results are not reproducible across runs, and your query will return different data each time it is evaluated. This is by design but must be understood: Number.Random is unsuitable for any scenario where reproducibility matters (such as test data, audit trails, or seeded samples). Power Query M has no built-in seed mechanism for random functions.

Caching behavior: Power Query's engine may cache the result of Number.Random() and reuse it across multiple rows if the expression is evaluated at the query level rather than the row level. To guarantee a unique value per row, call Number.Random() inside Table.AddColumn where the each keyword ensures row-by-row evaluation. Even then, caching behavior can vary by host environment (Power BI Desktop vs. Dataflow vs. Excel).

For a random number in a specific range, multiply: lower + Number.Random() * (upper - lower). Or use Number.RandomBetween(lower, upper) directly.

Examples

Example 1: Generate a single random number in [0, 1)

Result
Result
10.65

Example 2: Scale to a custom range [0, 100)

Result
Result
142.38

Example 3: Add a random priority score per row in a table

Table.AddColumn(
    Table.SelectColumns(Table.FirstN(Sales, 4), {"OrderID", "CustomerName"}),
    "RandomPriority",
    each Number.Round(Number.Random() * 100, 2),
    type number
)
Result
OrderID
CustomerName
RandomPriority
11Alice23.40
22Bob89.10
33Charlie51.20
44Alice4.70

Compatibility

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