OpenBI Docs Buy

RANDBETWEEN

A random whole number between two numbers, both included, different at each evaluation.

Group: Math. Compatible with DAX.

Syntax

RANDBETWEEN ( <bottom>, <top> )
ParameterTypeDescription
bottomWhole numberThe smallest number that may come out.
topWhole numberThe largest number that may come out; not below bottom.

Returns

Whole number. A random whole number from bottom to top, both included.

Remarks

  • Every call draws again, each row of a table included, and the results change whenever the query runs again.
  • A bottom above the top is an error. With bottom equal to top, that number is the answer.
  • A bound with decimals is taken inwards: the bottom rounded up, the top down. From 1.5 to 2.4 the only whole number is 2; from 1.2 to 1.9 there is none, and that is an error.
  • Each whole number in the range is equally likely.

Examples

A roll of a die

Your result will differ.

EVALUATE
ROW ( "Die", RANDBETWEEN ( 1, 6 ) )
Die
3

Five rolls

EVALUATE
ADDCOLUMNS ( GENERATESERIES ( 1, 5 ), "Roll", RANDBETWEEN ( 1, 6 ) )
ValueRoll
11
23
32
42
54

Bounds that leave one number

Equal bounds, and bounds with decimals that leave only 2 between them.

EVALUATE
ROW ( "From 5 to 5", RANDBETWEEN ( 5, 5 ), "From 1.5 to 2.4", RANDBETWEEN ( 1.5, 2.4 ) )
From 5 to 5From 1.5 to 2.4
52

RAND, SAMPLE, GENERATESERIES.

Last updated · OpenBI Studio 0.3.74