Referencing Foreign Groups & Headers


Most expressions within OpenGround are evaluated for a specific Group.

For example, in Templates, for most objects, you specify a Group, and then your Expression will reference Headers within that Group.

Similarly, for a Model Calculation, the expression applies to a specific calculated Header within a Group. Your expression will typically reference other Headers within that Group.

It is also possible for expressions to reference Headers from other “foreign” Groups, as described below.

Table of Contents

Parent Groups

In most scenarios, it is possible to reference a parent group in an expression.

For example, this is an example of a model calculation for an N60 Header in the SPT Group:

if(
  isblank([LocationDetails.EnergyRatio]),
  null,
  ([LocationDetails.EnergyRatio]/60) * [SPT.NValue]
)

In this example, the N60 calculation is performed in the SPT Group, and the EnergyRatio is stored in the LocationDetails group. In database terminology, the LocationDetails Group is a “parent” of the SPT Group. Each SPT record (child) belongs to a specific Location (parent).

An expression that references parent Groups like this is valid in most scenarios. (There is only one parent Location record for each SPT record, so the expression engine is able to work out which parent EnergyRatio value to use for the calculation.)

(One exception would be Import Mapping expressions, which often requires using special Lookup…() functions to reference parent tables in the source data.)

Sibling Groups

In most scenarios, it is not possible to reference a “sibling” Group within an expression. There are some exceptions as discussed below.

For example, say you were trying to use the expression below as a calculation from within in the SampleInformation Group to join the SampleReference (from SampleInformation) and GeologyCode (from StratumDetails) together with a colon in between:

[SampleInformation.SampleReference]+' :  '+[StratumDetails.GeologyCode]

In general, this expression would not work.

SampleInformation and StratumDetails are both direct “children” of LocationDetails, making them “siblings”. (There could be many StratumDetails records, and the expression engine wouldn’t know which record to use for each of the SampleInformation records.)

However, an exception where the above expression would work is in a Template if Depth Linking has been set up to link the StratumDetails Group to SampleInformation. In that scenario, the above expression would work. Depth-linked expressions are currently only supported in Templates and can’t be performed in Model Calculations or Data Collector expressions.

(Import Mapping expressions are also another exception, where again the special Lookup…() functions can be used to query sibling tables within the source data.)

Options Groups

Options are a special type of Group within OpenGround that can be used to control behavior in calculation expressions. They can exist at the Project or Location level. See here for more information.

Options can be referenced from expressions in Templates and Model Calculations.

They can’t currently be referenced in Data Collector or Import Mapping expressions.

Aggregation

Aggregation is an operation that combines values from multiple records into a single value.

Examples of aggregation include taking an average of multiple numerical values or joining multiple text values into a single text string.

Within OpenGround calculations, aggregation is typically performed on child records.

For example, the Moisture Content group is a child of the Sample Information group. Calculating the average Moisture Content (children) for each Sample (parent) would require aggregation. (There could be multiple Moisture Contents for each Sample).

Aggregation is performed slightly differently in Template Studio compared to Model Calculations. Please see our Aggregation in Templates and our Aggregation in Model Calculation guides for more information.

Aggregation is not generally supported in Import Mapping expressions and is limited within Data Collector to specific use cases such as using the Sum() function in a Calculated Value Expression.