Calculations
what is a calculation? a calculation is a similar to a measurement, with the difference that is computed based on other data in the historian it’s how you transform raw data into something more meaningful moving averages, status maps, efficiencies, etc a calculation takes 1 or more input measurements docid\ xqwlemdcnfff3 0h gmms or other calculations and writes the calculation result to the time series databases docid\ h4js6gcabog53kbawgyua why does it matter? raw measurements can be too limiting to give immediate insight calculations help you turn that raw data into operational metrics that are easier to monitor and act on they can help answer questions like how often did the temperature exceed the target? how much energy did we consume per ton of product? how much heat was exchanged over our heat exchanger? how does it fit in the system? calculations are defined in the historian and run on a schedule or when triggered, typically using one or more measurements or calculations as input a calculation script, written in the tengo language depending on the type of calculation, an aggregation function to run for each input measurement or calculation, before the data is passed to the calculation script an interval to run the calculation (predefined, or at the same resolution as the input for the calculation) here’s the flow calculated values are stored just like regular measurements and can be used in dashboards, alerts, or further calculations similarities with measurements just like with measurements, calculations have a name, description, datatype and destination database a quality history and can have engineering specifications (units of measurement, min/max, hi/lo levels) metadata and labels differences with measurements in contrast with measurements, calculations have one or more input measurements of calculations a tengo script context docid\ laphnbuhrbkojlq5cit r example let’s say you collect, for an input pump feeding a mixing vessel, the following measurements simulator/line 1/m1/p1/energyusage, aliased as energy with aggregation mean simulator/line 1/m1/p1/flowrate, aliased as flowrate with aggregation mean then you could define simulator/line 1/m1/p1/calcefficiency with the following script, to run every minute return flowrate value / energy value when you use it you’ll interact with calculations when you need aggregated or transformed data you want to monitor kpis or performance metrics you're building dashboards or reports that show trends over time you may configure calculations during system setup, but also later as users evolve their use of the system common misconceptions a calculation does not recalculate automatically if the calculation script of the source data changes historically you’ll need to manually reprocess it in that case a calculation is not the same as a formula in a dashboard calculations create a persisted time series, not a one off display value calculations don’t run in real time, they typically run at defined intervals (e g , every minute, hourly) best practices keep naming consistent and descriptive (e g , line2 speed avg 5min) document the calculation logic clearly, especially if it includes filters or conditions, with a description and comments in the script avoid overly complex calculations in a single script split the logic into multiple calculation scripts, and define outputs of calculations as inputs for other calculations more information creating a calculation docid 5ko0eady3x o y1jxd8cp how to use calculation context docid 9vedqpmtthzwuy1clkavh using metadata to reuse calculations docid\ vmelwzgf3ovtotokgj61q