Math Operator

Performs a mathematical operation on two or more values.

Syntax:

<math operator="-,+,*,/" format="NumberFormat">
<term1></term1>
<term2></term2>
<term3></term3>
<termn></termn>
</math>

Sample Code

If you want to add two numbers together:

<math operator="+" format="decimals:0;">
<term1>10</term1>
<term2>5</term2>
</math>

If you want to calculate the percentage of expected revenue relative to the opportunity amounts for the account by reading data in the Account object, you can use something like this:

<table>
<tr>
<th>Amount</th>
<th>Revenue Expected</th>
<th>Delta</th>
<th>Ratio</th>
</tr>
<aggregated_output_list object="Opportunity" relation="AccountId" group_by="">
<tr>
<td><aol_field name="Amount" alias="tot" aggregate_function="sum" format="decimals:2;separator:,;"/></td>
<td><aol_field name="ExpectedRevenue" alias="rev" aggregate_function="sum" format="decimals:2;separator:,;"/></td>
<td>
<math operator="-" format="decimals:2;separator:,;">
<term1><aol_field name="tot"/></term1>
<term2><aol_field name="rev"/></term2>
</math>
</td>
<td>
<math operator="*" format="decimals:1;">
<term1>
<math operator="/">
<term1><aol_field name="rev"/></term1>
<term2><aol_field name="tot"/></term2>
</math>
</term1>
<term2>100</term2>
</math>
</td>
</tr>
</aggregated_output_list>
</table>

If you want a grand total of amounts, you can use something like this:

<table>
<tr>
<th>Grand Total</th>
</tr>
<tr>
<td>
<math operator="+" format="decimals:2;separator:,;">
<term1>
<aggregated_output_list object="Opportunity" relation="AccountId" group_by="">
<aol_field name="Amount" alias="tot" aggregate_function="sum" format="decimals:2;separator:,;"/>
</aggregated_output_list>
</term1>
<term2>
<aggregated_output_list object="Opportunity" relation="AccountId" group_by="">
<aol_field name="Amount" alias="tot" aggregate_function="sum" format="decimals:2;separator:,;"/>
</aggregated_output_list>
</term2>
</math>
</td>
</tr>
</table>