Calculated Measures within Flow allows to one configure a measure’s previous period’s value, or even a previous range of values to be used in the calculation.
One can select one of 3 options for each measure in the measure dependant tree in the Retrieval section for a calculated measure. These option are:
- Current period
- Previous period
- Previous range
These option are located in the properties section of each measure
This is the default option. This will provide the current value of the measure for the time period it needs to preform a calculation on.
This option will allow the user to retrieve a value back in time relative to the current time period being processed. As an example, if you want to know what the value was 7 days ago relative to now, one will specify a relative end value of 7:
Flow will now use the previous period of this measure in your calculation expression.Notice Flow will add a "[-7]" in the measure name. This tells us we are looking at a value 7 days ago:
If we want a moving average, a total for a range of periods, or perhaps the minimum or maximum for a range, one would use the Previous range option
Lets assume we want to create a moving average for the past 30 days, we would configure the Relative Start to 30 and the Relative End to 0.
Flow will now return an array worth of 30 days of data.
This Relative Range calculation is useful for “moving window” calculations (e.g. moving average, moving sum, etc.)
Filler 1.Total Production.Daily (bottles)[-30, 0].Values.Average()
Filler 1.Total Production.Daily (bottles)[-30, 0].Values.Sum()
Filler 1.Total Production.Daily (bottles)[-30, 0].Values.Min()
Filler 1.Total Production.Daily (bottles)[-30, 0].Values.Max()
One can also pass the array to user defined function to preform additional calculations on the data.
One can now track your Daily Production (blue columns) against your baseline production(green dotted line) based on the 30 day moving average.