Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Find the lowest of 3 numbers in AMPScript
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: */
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
You can’t perform that action at this time.