AF Analytics - How to use Attributes from other Elements

Blog Post created by asoudek on Aug 31, 2016

(Use Attributes from other Elements in your expressions)

In some situations, there is a need to include Attributes from other Elements in the expression.  A typical example is a Parent-Element will contain information that the Child-Elements need for a
calculation.  Therefore, it would be great if we can reference Attributes from other Elements in the expressions.
You may also want to perform calculations (other than Rollups) that involve using values from parent and child-elements.  One way is to create additional Attributes in the current element and then reference the values from the parent and/or child-element.  This is not the best approach and not very flexible.  The better way is to reference these is inside the Analyses themselves. Well say no more.

In this example, we have well pads that have production targets and each well is to perform a calculation to determine the well’s production as a percent of the target production.  In the Figure below, Well Pad 1 is the Parent-Element has the Attribute Target Production.   Well Pad 1 also has Well Child-Elements.


The Wells then have an expression configured to retrieve the Target Production Attribute from the Parent-Element and perform the percent of target calculation, as shown in the Figure below.  The relative reference, ..\|Target Production, means go up to my Parent-Element and give me the value of the Attribute Target Production. (The Guide to AF and EF Substitution Syntax has more details on this type of syntax.)



If you are going to use Attributes from other Elements then it is a very good idea to only use relative references.  This also underscores the importance of following a standard when building PI AF


This example shows the syntax needed for referencing parent-element values and child-element values.  The following hierarchy is used for this example.


The Tank1 element needs to use the Total Inventory Attribute from the Well Pad1 Element.  In the Template for Tank, you can create an Expression and retrieve the value of Total Inventory
using the syntax below.  The name of the parent-element can change and your calculation will still be correct.


From the Well Pad1 Element you can write an Analysis that uses the Inventory Attribute from the child-element Tank1.  However, I have many child-elements and I do not want to specify the
name of the child-element because it will be different in other Well Pad Elements.  No worries, use the syntax below, which uses filters and collections to find the Tank Element based on its Template, no matter what its name is.  Note: There is another document called Guide to Substitution Syntax in AF-EF Data References which shows other ways to search for a child-element.