OpenBI Docs Buy

RAND

A random number from 0 up to 1, different at each evaluation.

Group: Math. Compatible with DAX.

Syntax

RAND ( )

It takes no parameters.

Returns

Number. A random number of 0 or more and below 1.

Remarks

  • Every call draws again: each row of a table gets its own number, and two calls in one formula give two numbers.
  • The results change whenever the query runs again, as when a visual refreshes.
  • For a number from a to b, use a + RAND () * ( b - a ); for whole numbers, RANDBETWEEN.
  • The numbers suit samples, simulations and test data, not passwords or keys.

Examples

One random number

Your result will differ.

EVALUATE
ROW ( "Random", RAND () )
Random
0.215825512349078

A number for every row

EVALUATE
ADDCOLUMNS ( GENERATESERIES ( 1, 3 ), "Random", RAND () )
ValueRandom
10.325853824616213
20.791323957743641
30.801265107904163

A random price from 10 to 20

EVALUATE
ROW ( "Price", 10 + RAND () * 10 )
Price
11.0616519312278

RANDBETWEEN, SAMPLE, GENERATESERIES.

Last updated · OpenBI Studio 0.3.74