Math Expressions

Cohesive supports simple math expressions. Users can perform basic arithmetic with the operators +, -, * , and / on number fields.

Basic Math

In the following example, let's assume that we have three number fields(unitPrice, quantity, and tax), and are looking to calculate a totalCharge field.

If we wanted to calculate totalCharge as the (unitPrice*quantity)+tax, we would put the following as the description for the totalCharge field (of type math expression). We can refer to other fields via the syntax {{fieldName}}, like in the example below.

{{unitPrice}} * {{quantity}} + {{tax}}

Note: if you intend to refer to a field that's within a nested field type, you need to append the nestedFieldName_ to the field name. For example, let's say that we have the below example. In order to refer to unitPrice, we would refer to it as item_unitPrice

Aggregating fields that are in a list

In some cases, you may have a list of items, and want to sum up or multiply together all the values in the list. For example, if we had an Excel table with four rows (that is represented as a List in Cohesive), you may want to sum up the values of a column for all four rows.

We provide 2 functions - SUM and PRODUCT. Continuing the example above, let's assume that we have a column called unitPrice within an item list that we're looking to sum or multiply.

Example 1: Description to sum all unitPrice values

SUM(item_unitPrice)

Example 2: Description to cross-multiply all unitPrice values

PRODUCT(item_unitPrice)

Note: you do not need the double curly braces to refer to other fields inside SUM and PRODUCT functions. To refer to a field inside a list, simply prefix the field name with listName_

Last updated