Rand

generate a random decimal number between 0 and 1.

The Rand() function in Power FX is used to generate a random decimal number between 0 (inclusive) and 1 (exclusive).

It is useful in scenarios where you need randomness in your app, such as for generating test data, randomizing user experiences, or adding unpredictability to your app's behavior.

Syntax

Rand()
  • This syntax generates a random decimal number greater than or equal to 0 and less than 1.

Example

Rand()

If you run this function, it might return a random number like 0.457298, but the value will change every time it is executed.

Example Use Case

You can randomize the display of certain components or items in your app.

For example, in your Product table, there is a column FilterValue where you assign a random decimal value to each of your products.

Then, in the Filtering of the View from... page, you could use:

ThisItem.FilterValue > Rand()

This randomly generates a value to compare with the ThisItem.FilterValue and show different set of products to your customers each time they visit your shopping app.

Last updated