Using the Expression Builder

The Expression Builder enables you to calculate a numeric field value by using a formula. The Expression Builder is available in any field that includes a Formula button (Σ). When a field includes a formula that was created and saved with the Expression Builder, an asterisk is displayed next to the Formula button. The system recalculates the formula and displays an updated value in the field each time the underlying data is changed and saved. You can modify an existing formula as needed.

To access the Expression Builder, click the Formula button in any field where it is included. The system displays the Expression Builder modal window.

You can view or enter information in these fields:

In the Expression field, enter a formula using standard python commands and syntax (see Supported Functions in the Expression Builder). Calculations can include conditional statements and these mathematical operators:   +    -    /    *    ^    ==    !=    <>    <    <=    >    >=    (    )

You can use the Field, Variable, and Predefined Formulas fields to add elements to the formula in the Expression field.

The Entity field displays the name of the entity associated with the field from which the Expression Builder was accessed. In the Field box, you can select a field from the associated entity or its child entities. When you select a field, the system enters the selection in the Expression field and clears the Field box.

In the Variable field, you can select a variable that has been defined either for a cost estimate (see Maintaining Variables for a Cost Estimate) or a typical section (see Maintaining Variables for a Typical Section Profile). When you select a variable, the system enters the selection in the Expression field and clears the Variable field.

In the Predefined Formulas field, you can select a reference formula that has been recorded in the system (see Working with Formulas). When you select a formula name, the system enters the contents of the formula in the Expression field and clears the Predefined Formulas field.

To calculate the expression and check the syntax, click the Evaluate button. The system either displays the product of the calculation in the Result field, or it displays a message that the formula is invalid. You can modify the expression as needed.

To save the expression and enter the result of the calculation as the field value, click the Save button. The system closes the modal window and enters the result in the field from which the Expression Builder was accessed. The expression is also saved as part of the field and can be modified again as needed.

Formula Examples

Cost Estimate Typical Section Items Quantity Per Unit field can be calculated by accessing stored variables on the Cost Estimate Typical Section.

  print Variable(?VariableName?) * Variable (?VariableName?)

Conditional Statements:

LoadProperty[insert the Entity you are in](Entity, ?insert the Entity you are stepping up to?)
Field = Entity.EntityName.EntityField[# row appears in the lists starting with 0)
print a value
else
print a different value

This would look like:

LoadProperty[CostEstimateItem](Entity,'CostEstimate')
LoadProperty[CostEstimate](Entity.CostEstimate,'CostEstimateMarkups')
Markup = Entity.CostEstimate.CostEstimateMarkups[0]
if Markup.Amount > 500:
 print 10
else:
 print 20

Stepping up into parent entities:

LoadProperty[Entity you are in](Entity, 'Entity you are stepping up to')
if ParentEntity.ChildEntity.Field > value:
 print value
else
 print a different value

This would look like:

LoadProperty[CostEstimateItem](Entity,'CostEstimate')
if Entity.CostEstimate.Lanemiles > 500:
 print 10
else:
 print 30

Stepping up into a parent entity and calling a field name to use in the formula:

LoadProperty[Entity you are in](Entity, 'Entity you are stepping up to')
print ParentEntity.ChildEntity.Field * 2

This would look like:

LoadProperty[CostEstimateItem](Entity,'CostEstimate')
print Entity.CostEstimate.Lanemiles * 2

Stepping down into children entities:

LoadProperty[Entity You are in](Entity,'Entity you are stepping down to')
LoadProperty[Entity you stepped down to](Entity.Parent Entity,'Child Entity')
Field = Entity.Parent.Child[Row starting with 0]
print Entity.Field

This would look like:

LoadProperty[CostEstimateItem](Entity,'CostEstimate')
LoadProperty[CostEstimate](Entity.CostEstimate,'CostEstimateMarkups')
Markup = Entity.CostEstimate.CostEstimateMarkups[0]
print Markup.Amount
Displaying formula.txt.

Related topics:

Working with Formulas

Maintaining a Formula

Supported Functions in the Expression Builder

 

Blue bar indicating the end of the topic