Expression Builder

The Expression Builder allows for database fields to be calculated using expressions without the need for custom extensions.

Important Notes:

  • Expressions are written using C# language. This is the same language that is used in Rapid Reserver Parcel Mappings when creating a resmodel.

  • Expressions can only populate blank fields; they cannot be used to update mapped fields.

  • Expressions can only reference fields ‘above’ them in the list. This is to avoid circular references.

  • Expressions can only reference Solid Fields that are common to the Activity. Meaning Mining Expressions cannot reference fields from a blast solid or drilling field collection.

  • Can be used with Extensions.

    • Extensions will run after Expressions are applied. Meaning if an expression is used to calculate a field, and extensions are also calculating that field, the extensions value will replace the expression value. This is why there are multiple database steps (Expression Refined & Extension Refined) to view the data as it’s being processed.

    • Expressions can use inputs from a scripted refinement inputs table. However, any reference to a scripted field will have no relationship to the database when referenced in expressions.

    • Extensions cannot reference Table Setup created inputs. This is to avoid changes in Table Inputs causing reference errors in Extensions.


Expression Builder

Area

Usage

Field Collection

Displays a list of all Field collections in the model.  Selecting a field collection will display any associated fields that available to be calculated.

Expression Panel

By Parcel

  • Expressions are always run at the parcel level, even if they are entered at the parent level. If the same expression will be used for all parcels, then it can be entered at the parent level.   However, if different Expressions are to be used for each Parcel, ticking this option on will display each parcel and expressions can be added for each.

  • Simple Example: If you have an activity with 5 parcels and entered 1 into the Expression at the parent level, when you look at the data each parcel will report 1 and the parent level will report 5.

Field Name – The name of the field available to have an Expression applied.   Only unmapped fields will appear in this list.

Expression – Expression to be evaluated.

Cog Button

  • Used to open Edit Expression window. Same functionality as the panel, but with more space.

  • Tip: Comments can be added to the expressions to make them easier to read. Use /* to start a comment and */ to end it.

Inputs Panel

Fields

  • List of database fields which are available to be referenced in the expression.

  • Fields can be added to an Expression by double clicking or drag and drop.

  • When fields are added to an Expression, they will have T or N added in front of them.  This indicates if the field is Text or a Number

Refinement Inputs

  • List of inputs created from the inputs table.

  • It is important to note that some Refinement Inputs are highlighted and contain the database field name with <> symbols around them. These inputs act as ‘wildcards’ and will automatically use the correct field from the input table based on the database field being referenced. For example, rather than using an if statement to cycle through each blast type to get Diameter, one can use the wildcard.

  • When Refinement Inputs are added to an Expression, they will have RT or RN added in front of them.  This indicates if the input is Text or a Number

Available Formulas

Contains a list of common formulas to assist in Expressions.

Parcel – Returns name of current parcel.

Pi – Returns mathematical value for Pi.

Pow – Used to raise a number to a specified power.

Min/Max – Used to return the smallest/largest value.

Round – Used to round to a whole number or specified number of digits.

N(Field, ParcelName) – Returns the field value for the specified parcel.  If ParcelName is not defined, value returned will be the value at the parent level.

double.Parse(Text) – Used to convert text to numerical values, even if the input looks like a number.  For example, drill parcels of 165 & 251 ‘visually appear’ as numbers but are stored as text. In order to use them mathematically, one must first convert them to a double using this formula.

Note: Formulas are case sensitive.

For more information, see: Exercises: Expression Builder Walkthrough