OpenBI Docs Buy

Number.RandomBetween

A random number between a bottom and a top you give, fractions included.

Group: Number. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Number.RandomBetween(bottom as number, top as number) as number
ParameterTypeDescription
bottomnumberThe smallest number it may give.
topnumberThe largest; it must not be below the bottom.

Returns

number. A random number from the bottom to the top, with a fraction: round it for a whole number.

Remarks

  • Each call, and each refresh, gives another number. With the bottom equal to the top, that number comes back.
  • A top below the bottom is an error.

Examples

A delivery time of 2 to 5 days

Number.RandomBetween(2, 5)
3.9847967832972104

A test price within 5 per cent of 200

Number.Round(200 * Number.RandomBetween(0.95, 1.05), 2)
205.25

The top below the bottom

Number.RandomBetween(10, 1)

Result: an error.

[Reason = "Expression.Error", Message = "The 'top' argument cannot be less than 'bottom'.", Detail = 1]

Number.Random, List.Random, Number.Round.

Last updated · OpenBI Studio 0.3.79