Tutorial: writing expressions

The tutorial illustrates how to write expressions in different ways.

Show me how

For a demonstration of how to write expressions that use integer, decimal, and currency fields, see the following video. You also learn how to use parentheses for precedence and how to apply operands to lists and dates.

Basic expressions

Let's start with some basic expressions, where the operation type is Variable.

Table 1. Examples of basic expressions
Operation name Expression Result Note
N1 1 + 2 N1 is set to 3  
D1 2020-10-10 + 2 D1 is set to 2020-10-12  
S1 "abc" + "def" S1 is set to abcdef  

Expressions that use operation names

Then, to use those operations in expressions in subsequent operations, enclose the operation name in [$$], as shown in the following examples:

Table 2. Examples of expressions that use operation names
Expression Result Note
([$N1$] * 2)+100 106 Where N1 contains the expression, 1 + 2
[$D1$] + 10 2020-10-22 Where D1 contains the expression, 2020-10-10 + 2
[$S1$] + [$S2$] abcdefxyz Where S1 and S2 contain the string values abcdef and xyz, respectively

Expressions that use object fields

Expressions can retrieve values from object fields, as shown in the following examples:

Table 3. Examples of expressions that use object fields
Expression Result Note
[$Field Group:Number1$] + [$Field Group:Number2$] 3 Where the value in Number1 is 1 and Number2 is 2
[$Field Group:Date1$] + 2 2020-10-12 Where the value in Date1 is 2020-10-10
[$Field Group:String1$] + [$Field Group:String2$] abcdefxyz Where the value in String1 is abcdef and String2 is xyz

Expressions that mix operation names and object fields

You can mix operation names and object fields in an expression, as shown in the following examples:

Table 4. Examples of basic expressions that mix operation names and fields names
Expression Result Note
[$N1$] * [$Field Group:Number3$] 300 Where Number3 contains 100.
[$D1$] + 10 2020-10-22 Where [$D1$] contains the expression, 2020-10-10 + 2
[$S1$] + [$Field Group:Description$] abcdefDescription value Where [$Field Group:Description$] contains Description value

Expressions that use functions

You can apply functions to values, fields, and operations, as shown in the following examples:

Table 5. Examples of functions that are applied to values, fields, and operations.
Expression Result Note
max(5000, 10000, 15000, 20000) 20000 The max function finds the maximum value in a list.
max ([$Child:LossImpact/OPSS-LossIm:Estimated Loss$]) 20000.00 Where four child objects contain the following values in the Estimated Loss field: 5000.00, 10000.00, 15000.00, 20000.00
max ([$Loss1$],[$Loss2$], [$Loss3$], [$Loss4$]) 20000.00 Where the four operations that are given contain the following values: 5000.00, 10000.00, 15000.00, 20000.00
count ([$Child:LossImpact/OPSS-LossIm:Estimated Loss$]) 4 Number of items