Follow

Evaluating Numbers

 
Table of Contents
  1. 1. Overview
  2. 2. Tags
  3. 3. Related

Overview

Several Logic Tags are used to evaluate numeric values and output results to the content.

Tags

Values may be Integer, Date, or Float, and can be literal (defined within brackets [1]), variable (set in the template %%set value1 = 1%%), date part ($customDate.month), builtin (builtin.today - without preceding $), or Subscriber or Custom Data ($customNumber).

 

Tag %%eval add INT1 INTn%%
Parameters INT: Integer Literal, Variable, Date Part, Custom Data, or Subscriber Data
Output Output the sum of 1 to n integer values.
Example %%set int1 = 1%%
%%eval add $int1 [1]%%
Results 2
   
Tag %%eval addfloat FLOAT1 FLOATn [p=P]%%
Parameters FLOAT: Float Literal, Variable, Custom Data, or Subscriber Data
P: integer greater than 0 to indicate precision
Output Output the sum of 1 to n integer values with the precision of P values after the decimal.
Example %%set float1 = 1.25%%
%%eval add $float1 [1.25] [p=2]%%
Results 2.5
   
Tag %%eval div INT1 INTn%%
Parameters INT: Integer Literal, Variable, Date Part, Custom Data, or Subscriber Data
Output Output the result of dividing one integer value by another. Float values are returned rounded to the second place. Use EVAL FORMATNUMBER to display the value as desired.
Example %%set int4 = 4%%
%%eval div $int4 [2]%%
Results 2
Example %%set int1 = 1%%
%%set int4 = 4%%
%%eval div $int1 $int4%%
Results 0.25
   
Tag %%eval expr (EXPRESSION)%%
Parameters EXPRESSION: Mathematical expression using + (add), - (subtract), * (multiply), and / (divide), supported by nested expressions with parenthesis.
Output Output the result of the mathematical expression. Float values are returned rounded to the second place. Use EVAL FORMATNUMBER to display the value as desired.
Example %%set int55 = 55%%
%%eval expr ($int55 / 11)%%
Results 5
Example %%set int163 = 1%%
%%set int34198 = 34198%%
%%set int40802 = 40802%%
%%eval expr ($int163 * ($int34198 / ($int34198 + $int40802)))%%
Results 74.32
   
Tag %%eval formatnumber FORMAT VALUE%%
Parameters FORMAT: Set variable with defined format. To define format, use 0 to indicate a decimal "0" value should be displayed. Use # to inidcate a decimal "0" should be dropped.
VALUE: Integer or Float Literal, Variable, Date Part, Custom Data, or Subscriber Data
Output Output the result of applying a specified number format to a value. Numbers will be rounded up when decimals are dropped.
Example %%set value = "12342342.004232"%%
%%set formatNumber = "#,##0.00"%%
%%eval formatnumber $formatNumber $value%%
Results 12,342,342.00
Example %%set value = "12342342.004232"%%
%%set formatNumber = "#,##0.#"%%
%%eval formatnumber $formatNumber $value%%
Results 12,342,342
Example %%set value = "12342342.004232"%%
%%set formatNumber = "0.0"%%
%%eval formatnumber $formatNumber $value%%
Results 12342342
   
Tag %%eval max INT1 INT2%%
Parameters INT: Integer Literal, Variable, Date Part, Custom Data, or Subscriber Data
Output Output the larger of two integer values.
Example %%set int8 = 2%%
%%eval max $int8 [8]%%
Results 8
   
Tag %%eval min INT1 INT2%%
Parameters INT: Integer Literal, Variable, Date Part, Custom Data, or Subscriber Data
Output Output the smaller of two integer values.
Example %%set int7 = 2%%
%%eval min $int7 [8]%%
Results 2
   
Tag %%eval mod INT1 INT2%%
Parameters INT: Integer Literal, Variable, Date Part, Custom Data, or Subscriber Data
Output Output the remainder of dividing one integer value by another.
Example %%set int6 = 12%%
%%eval mod $int6 [5]%%
Results 2
   
Tag %%eval mult VALUE1 VALUEn%%
Parameters VALUE: Integer or Float Literal, Variable, Date Part, Custom Data, or Subscriber Data
Output Output the result of multiplying one to n integer values together. Supports both integer and float values. Float values are returned rounded to the second place. Use EVAL FORMATNUMBER to display the value as desired.
Example %%set int3 = 2%%
%%eval mult $int3 [1]%%
Results 2
Example %%set int3 = 3%%
%%set float2d5 = 2.5%%
%%eval mult $int3 $float2d5%%
Results 7.5
   
Tag %%eval rand INT1 INT2%%
Parameters INT: Integer Literal, Variable, Date Part, Custom Data, or Subscriber Data
Output Output a random integer value between the two defined integer values.
Example %%eval rand [1] [8]%%
Example %%set int9 = 1%%
%%eval rand $int9 [8]%%
Results A random number between 1 and 8
   
Tag %%eval sub INT1 INTn%%
Parameters INT: Integer Literal, Variable, Date Part, Custom Data, or Subscriber Data
Output Output the result of subtracting one integer from another.
Example %%set int2 = 4%%
%%eval sub $int2 [2]%%
Results 2
   
Tag %%eval subfloat FLOAT1 FLOATn [p=P]%%
Parameters FLOAT: Float Literal, Variable, Custom Data, or Subscriber Data
P: Integer greater than 0 to indicate precision
Output Output the result of subtracting one float value from another.
Example %%set float2 = 3.75%%
%%eval sub $float2 [1.25] [p=2]%%
Results 2.5

 

 
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk