Description
The RandomGen Generator randomly generates a number within a range. For example, you can use it to generate random ages between 18 and 65.
In This Article
- Generator Parameters
- Example 1 - Generate Random Numbers Between 1 and 1000 with No Unique Limit
- Example 2 - Generate Random Numbers Between 1 and 10 with a Unique Limit of 2
- Error - Exhausted Attempts to Find the Next Valid Random Value
Generator Parameters
The following parameters may be configured for the RandomGen Generator. Items with an asterisk* are required.
- startRange* - Defines the start range of the random Generator.
- endRange* - Defines the end range of the random Generator.
- uniqueLimit - Defines the number of times a given value is allowed to be regenerated. The value should be 1 or greater.
- If uniqueLimit is left empty, there is no limit to how many times a value can be regenerated.
- If a value is entered, then each number within the range can be generated that number of times.
- If 1, each value will only be generated once.
- If 10, each value will be generated ten times.
- The uniqueLimit does not apply to dynamic start and end range values that change per row.
- seed - Using the seed will ensure that the same random data is generated each time data is generated.
Example 1 - Generate Random Numbers Between 1 and 1000 with No Unique Limit
Sample Output
Example 2 - Generate Random Numbers Between 1 and 10 with a Unique Limit of 2
For this example, the Domain loopCount has been set to 15 records to ensure the possibilities are not exhausted during test data generation.
Each number ranging from 1 to 10 can only be generated 2 times.
Sample Output
The following output has been generated as a delimited file:
Error - Exhausted Attempts to Find the Next Valid Random Value
You will receive an error if a value is present for the uniqueLimit parameter, and the loopCount exceeds the maximum number of values generated based on that limit.
For example, the range is between 1 and 20, and the uniqueLimit is '1', while the Domain loopCount has been set to '20'.
!!!!! An Error Has Occurred !!!!! strings: Exhausted attempts to find the next valid random value from range of 1 to 20.
Here are a few ways this error can be resolved:
- Increase the Domain loopCount - generates more records
- Increase the endRange parameter value - generates a larger data set
- Increase the uniqueLimit parameter value - values will be generated more often (e.g., if 3, each will be generated 3 times)