The Random function returns a random whole number between two numbers that is specified in the function.
Use case: the function can be used to randomly choose a number if you wanted to show content based on that value.Random
Note that this function only returns one number between two whole integers that is specified in the function.
Syntax:
Random(1,2)
1 = Number of the lowest number in the range of numbers
2 = Number of the highest number in the range of numbers
Example:
%%[
set @numberValue1 = “1”
set @numberValue2 = “100”
set @randomValue = Random(@numberValue1, @numberValue2)
if @randomValue > ’50’ then
set @msg = ‘Winner’
elseif @randomValue < '50' then
set @msg = 'Loser'
endif
]%%
%%=v(@randomValue)=%%
%%=v(@msg)=%%
Output:
69 Winner
Explanation:
In the example above, the range is set from 1 to 100 so the function will pick a random number anywhere from 1 to 100. Then we wrap an RandomIF function with the variable for @randomValue and if the randomly selected number is above 50 then the message of “Winner” is displayed. If the random value is below 50 then the message of “Loser” is displayed.
The function only displays integers or whole numbers. It can be used in a variety of ways. Instead of showing the Random@msg variable, different pieces of content in an email can be displayed based on the random output from the function.Random
Related functions are the Divide, Add, Multiply, and Subtract functions