RANDBETWEEN DAX Function (Math and Trig) Volatile
Returns a random number between the numbers you specify.
Syntax
| Parameter | Attributes | Description | 
|---|---|---|
| Bottom | 
                                         The smallest integer RANDBETWEEN will return.  | 
                                |
| Top | 
                                         The largest integer RANDBETWEEN will return.  | 
                                
Return values
A random integer number between Bottom and Top, which are included in the range of the possible integer results.
If Bottom is greater than Top, then RANDSBETWEEN raises an error.
Examples
--  RAND returns a random number between 0 and 1
--  RANDBETWEEN returns a random number between 
--  the two provide boundaries
DEFINE 
    VAR Vals = GENERATESERIES ( 1, 10, 1 )
VAR Random = 
    ADDCOLUMNS ( 
        Vals,
        "RAND",        RAND (),
        "RANDBETWEEN", RANDBETWEEN (-[Value], +[Value] )
    )
EVALUATE
    Random
EVALUATE
    {
        ( "Random Average (around 0.5)",  AVERAGEX ( Random, [RAND] ) ),
        ( "RandBetween Avg (near 0)",      AVERAGEX ( Random, [RANDBETWEEN] ) ),
        ( "RandBetween Min (near -10000)", MINX ( Random, [RANDBETWEEN] ) ),
        ( "RandBetween Max (near  10000)", MAXX ( Random, [RANDBETWEEN] ) )
    }
| Value | RAND | RANDBETWEEN | 
|---|---|---|
| 1 | 0.31 | 0 | 
| 2 | 0.87 | 2 | 
| 3 | 0.54 | 0 | 
| 4 | 0.91 | 1 | 
| 5 | 0.24 | 3 | 
| 6 | 0.40 | 2 | 
| 7 | 0.39 | -6 | 
| 8 | 0.40 | 6 | 
| 9 | 0.99 | -6 | 
| 10 | 0.41 | 1 | 
| Value1 | Value2 | 
|---|---|
| Random Average (around 0.5) | 0.55 | 
| RandBetween Avg (near 0) | 0.30 | 
| RandBetween Min (near -10000) | -6.00 | 
| RandBetween Max (near 10000) | 6.00 | 
Related functions
Other related functions are:
Last update: Oct 22, 2025 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber
Microsoft documentation: https://docs.microsoft.com/en-us/dax/randbetween-function-dax
