RANDfunction generates a random real number between 0 and 1. The function accepts an optional integer parameter, which causes the same set of random numbers to be generated with each job execution.
- This function generates values of Decimal type with fifteen digits of precision after the decimal point. If you want to see all digits in the generated value, you might need to apply a different number format. See NUMFORMAT Function.
- New random numbers are generated within the browser, after each browser refresh, and between subsequent job executions.
Optionally, you can insert an integer as a parameter.
- When this value is present, this seed value is used as part of the random number generator such that its output is a set of pseudo-random values, which are consistent between job executions.
- When the browser is refreshed, the random numbers remain consistent when the seed value is present.
derive type:single value: RAND() as:'random'
Output: For each row, generate a random number between 0 and 1 in the new
There are no arguments for this function.
Example - Random values
In the following example, the
random column is generated by the
derive type:single value:RAND() as:'random'
Example - Type check functions
RAND function is typically used to introduce randomness of some kind in your data. In the following example, it is used to perform sampling within your wider dataset.
Tip: Keep in mind that for larger datasets the application displays only a sample of them. This method of randomization is applied to the full dataset during job execution.
You want to extract a random sample of 20% of your set of orders for further study:
You can use the following transform to generate a random integer from one to 10:
derive type:single value:round(RAND() * 10) as:'random'
You can now use the following transform to keep only the rows that contain random values that are in the top 20%, where the value is
keep row:(random > 8)
NOTE: Since the results are randomized, your results might vary.