Created
November 11, 2016 14:41
-
-
Save wvpv/12ad4a3c68d466f66aae592e2f16c9f2 to your computer and use it in GitHub Desktop.
Find the lowest of 3 numbers in AMPScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%[ | |
var @num1, @num2, @num3, @lowestNum | |
/* force strings to be numbers */ | |
set @num1 = add('105.54',0) | |
set @num2 = add('88.73',0) | |
set @num3 = add('106.32',0) | |
/* find lowest with method outlined here: http://stackoverflow.com/a/9424226/812377 */ | |
set @lowestNum = iif(@num1 < iif(@num2 < @num3, @num2, @num3), @num1, iif(@num2 < @num3, @num2, @num3)) | |
]%% | |
<br>num1: %%=v(@num1)=%% | |
<br>num2: %%=v(@num2)=%% | |
<br>num3: %%=v(@num3)=%% | |
<br>lowestNum: %%=v(@lowestNum)=%% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment