Result
Understand how to create a calculated measure by using the calculator icon in the "Flow Zone".
Tutorial steps
- Create a Calculated Measure - Drag the Steam Production Hourly Measure on to the calculator icon in the "Flow Zone" to create a calculated measure
- Add another Dependent Measure - Add the manual rating tag to the dependency of the calculation
- Create an Efficiency Calculation - Create a calculation to determine the efficiency of the boiler
Create a Calculated Measure
Now that you have a measure for the Boiler’s actual production (ton/hr) and a measure specifying the Boiler’s design rating (ton/hr), you can do the necessary comparison to determine how well your Boiler is performing.
Flow allows you to create calculations based on other measures within your Flow System. You are now going to create a Calculated Measure that indicates the Efficiency (%) of the Boiler against its design rating.
Drag the "Production (ton/hr)" measure onto the Flow Zone Calculator icon …
Flow will create and configure a new Calculated Measure. Name the new measure "Production Efficiency". By default, the UOM will be the same as the measure you dragged to create the calculated measure, in this case, "ton/hr".
You will notice the red disk displayed on the new measure’s icon. This indicates that it has a problem. Hover your cursor over the measure to see a message, "Calculation has not been validated". This is normal after creating a new Calculated Measure (and you've seen this before in a previous tutorial...) You need to open the measure’s editor and expand the "Retrieval" section …
For a Calculated Measure, the "Retrieval" tab displays two sections:
- Dependents – the calculation dependents are displayed on the left. Calculations in Flow are defined by a Date and Time from which the calculation is valid. Additional calculations can be added to the dependency tree, as long as they have a different Date and Time. This mechanism provides the ability to change calculations over time, but not lose the ability to backfill a measure to a time when a different calculation was used.
- Expression – the expression on the right is the actual calculation, which is defined using Microsoft.NET’s C# syntax. Flow simplifies the "writing" of the expression by supporting double-click and drag ‘n drop into the expression.
You will see the "Production (ton/hr)" measure has already been added to the dependency tree. If you ever want to verify where a dependent measure resides in the Model View, right-click on the measure in the calculation dependents tree, and select Show in Model - the measure will then be located and highlighted in the Model View tree.
Drag the "Production Rating (ton/hr)" measure from the Model View onto the Date and Time in the dependency tree.
Now edit the expression as follows to calculate the Efficiency of the Boiler as a percentage. After placing your cursor in the expression, you can double-click the measure in the dependency tree to place the relevant text into the expression at your cursor position. Alternatively, you can drag the measure from the dependency tree into the expression.
Once you are happy with your calculation’s expression, click the "check" button to validate the expression. If there are no problems with your expression, Flow will save it and you will notice the red disk disappears.
Ensure that you have the correct properties for your measure, specifically the following:
- Fomat - 0.00
- Unit - %
Deploy the calculated measure and confirm that it is generating a percentage for the Boiler’s Efficiency.
Notice that the calculation expression makes use of the ".Value" property of a measure. The "Insert" button allows you to use other properties of a measure (e.g. ".Quality", ".Duration" in milliseconds, ".PeriodStart" and ".PeriodEnd")
Calculation "Date and Time" You will notice in the calculation dependency tree that a calculation’s dependents and its expression are defined by a date and time. This represents the date and time from which this calculation is valid. This functionality allows for calculations to change over time (e.g. water reticulation calculation changes because of a new meter installation), but still maintain data integrity during a measure "backfill".