RandBetween

generate a random integer within a specified range.

The RandBetween function in Power FX is used to generate a random integer within a specified range.

It’s particularly useful when you need to introduce an element of unpredictability in your app, such as assigning random IDs, selecting random items, or simulating random events.

Syntax

RandBetween(Lower, Upper)
  • Lower: The minimum integer in the range (inclusive).

  • Upper: The maximum integer in the range (inclusive).

You can also assign a column of Number data for the value of Lower and Upper:

RandBetween(ThisItem.MinNumberColumn, ThisItem.MaxNumberColumn)

When called, RandBetween returns a random integer between the two provided values, Lower and Upper.

The values returned are uniformly distributed, meaning that every integer within the range has an equal chance of being selected.

Example

Let's say you want to generate a random number between 1 and 100:

RandBetween(1, 100)

Result: 43, 84, or any value within 1 and 100.

Last updated