Category: Number
Syntax: Random |
Parameters: None
Data type returned: Number
Description:
Returns a random decimal between zero and one (but will not return 1 nor 0.) When used in a field definition, a new value is generated when the formula is updated. It is also updated anytime the formula re-evaluates, such as when other field values referenced in the formula change. In an unstored calculation, the Random() function re-evaluates each time the field is displayed.
If you want to generate a random integer in a certain range, multiply the result returned by the random function by the range you want to produce; then use the Int(), Floor(), Ceiling(), Round(), or truncate() functions to remove the decimals.
For instance, to return a random number from 1 to 6 (as in the roll of a die), use the formula:
Ceiling (Random * 6)
If you need to specify a lower bound for the random number, just add the bound to the results of the random number. For instance, to return a random number between 10 and 100, inclusive, use the following formula:
Int (Random * 91) + 10
Examples:
Function | Results |
---|---|
Round (Random; 5) | Might return .07156. |
: FileMaker Specifications
FileMaker 8 Product Line
Specifications and Storage Limits
Field Types and Import/Export Formats
: Calculation Functions
Working with Calculations Primer
Calculation Signatures
Calculation Functions
: Custom Functions
Custom Functions Primer
Useful Custom Functions
: Script Steps
Scripting Primer
Script Step Reference
: Quick Reference
FileMaker Error Codes
FileMaker Keyboard Shortcuts
FileMaker Network Ports
FileMaker Server Command Line Reference
FileMaker XML Reference
: Other Resources
Where to Go for More Information