Iterator expressions in dynamic drawing elements
- Last UpdatedJan 24, 2023
- 2 minute read
- PI System
- RtReports 5.0
- Visualization
Iterator expressions programmatically loop through repeatable data journal elements. They control the current context of the source expressions that are used.
You often want to show repeating data in reports, such as production summary reports, clean utility reports, computer usage reports, etc., with each repeating section in the report, such as phase or hourly energy usage, using the same format.
For each of these examples, you can create a standard format template section and then apply it to a the repeatable elements in the data journal, such as a Unit, Phase, or even a particular type of action or result, such as an exception.
You define iterator expressions in the Iterator field when editing the dynamic drawing element.
You populate the Iterator property in one of two ways:
-
Click the Journal tab, navigate to the element, then drag and drop it into the Iterator field of the dynamic drawing element Edit window.
-
RtReports editor automatically populates the iterator expression.
-
Manually construct the iterator expression.
Drag and drop elements into the Iterator field
In this example, we want to use an iterator expression to generate format template sections for each PI UnitBatch. To do this, the iterator expression must loop through the UnitBatchJournals collection within the data journal.
-
Add a section element to the format template.
The Section Edit window opens.
-
Click the Expressions tab and locate the Iterator field. Leave this window open.
-
Switch to the Journal pane, and navigate to the UnitBatchJournal element in the data journal tree.
-
Drag and drop the first UnitBatchJournal element into the Iterator field of the Section Edit window.
The section element you added to the format template creates a report section for every UnitBatchJournal element in the data journal.
The iterator expression sets the current source expression context to:
BatchJournal/UnitBatchJournals/UnitBatchJournal
If you add a data element to this section, you must use a relative reference to the data journal element that you want to include.
Note: If the RtReports editor cannot determine the proper iterator expression acting on the source expression, it enters an absolute source expression. You must manually edit the iterator expression to change it.
Iterator expression syntax
Iterator expressions use the same syntax as source expressions. For more information, see Source expressions in dynamic drawing elements.