Number.Random
NumberReturns a random number between 0 (inclusive) and 1 (exclusive). The value changes on each call.
Syntax
Number.Random() as numberReturn Value
number — A 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 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
)OrderID | CustomerName | RandomPriority | |
|---|---|---|---|
| 1 | 1 | Alice | 23.40 |
| 2 | 2 | Bob | 89.10 |
| 3 | 3 | Charlie | 51.20 |
| 4 | 4 | Alice | 4.70 |