Follow

What are Calculation Extensions, and how do I use them?

This article will be updated in the near future! In the meanwhile, if the following information is insufficient, contact support@flow-software.com.

A number of extensions are available when creating a calculation in Flow. These extensions allow you to access contextual information that Flow is tracking, which allows you to compute context-rich KPIs.

CalculationExtensions-ContextMenu-InsertOptions.png

When you add a measure (the “source measure”) as a dependant to a calculation (the “calculated measure”), you can access the following properties from the source measure.

In the following example, the source measure has:

  • Both Time and Event context
  • The Time context is called Production
  • The Event context is called Filler 2 Run, with the following Event Attributes:
    • Case Configuration - e.g. 3x2; 6x4
    • Line - e.g. PK001
    • Line Rating (bottles/hr) – e.g. 18000; 36000
    • Line Rating (cases/hr) – e.g. 3000; 15000
    • SKU Description – e.g. Grape 250ml; Apple 2000ml
    • Volume per Container – e.g. 250; 2000
    • Bottles per case – e.g. 30
  • The source measure also has a limit called New Limit

Assuming the calculated measure has both the time and event context (must be the same, e.g. Filler 2 Run), then the calculated measure can access the following properties of the source measure to use in its calculation.

NOTE: The Flow engine processes the “Time Periods” and “Event Periods” separately for all measures.  Therefore, certain properties are only available in one of the period types and will return NULL in the other period type.  It is recommended that you check whether the engine is processing a Time Period or an Event Period and configure different calculations for both.

Condition Extensions

The condition extensions return a Boolean (true/false) value which can be used in a conditional statement (e.g. If) to perform other functions.

  • Period.IsTimePeriod: will be true if this calculation is for the time period context of the calculated measure
  • Period.IsEventPeriod: will be true if this calculation is for the event period context of the calculated measure
  • Source Measure.Limits["New Limit"].High: is true if the measure being referenced has a high limit exception for the interval being processed, for the limit specified within the []
  • Source Measure.Limits["New Limit"].Low: is true if the measure being referenced has a low limit exception for the interval being processed, for the limit specified within the []
  • Source Measure.Limits["New Limit"].Exception: is true if the measure being referenced has any limit exception for the interval being processed, for the limit specified within the []

Context Extensions

  • Context.Name: The Calendar name when processing a time period; the Event name when processing an event period
  • Context.Attribute: Only valid when processing a time period.  Null when processing the null attribute, or the name of the attribute currently being evaluated by the engine.
  • Context.AttributeValue: Only valid when processing a time period. Null when processing the null attribute, or the value selected/entered for the attribute being processed
  • Context.Attributes: Only valid when processing an event period. Null when processing time period.  When processing an event period, this returns a dictionary of all the attributes and attribute values for the event period being processed.

Measure Extensions

  • Source Measure.Value: this is the default extension when adding a measure to a calculation. Returns the actual value of the referenced measure for the interval being processed.
  • Source Measure.Quality: returns the quality of the referenced measure for the interval being processed.
  • Source Measure.Duration: the duration (in ms) for the time period / time slice being processed
  • Source Measure.Limits["New Limit"].HighValue: Returns the value of the High value that is configured in Source Measure, for the Limit specified within the [].  Only works if the value specified is a constant, and not a linked measure.
  • Source Measure.Limits["New Limit"].Target: Returns the value of the Target value that is configured in Source Measure, for the Limit specified within the []  Only works if the value specified is a constant, and not a linked measure.
  • Source Measure.Limits["New Limit"].LowValue: Returns the value of the Low value that is configured in Source Measure, for the Limit specified within the []  Only works if the value specified is a constant, and not a linked measure.

Event Extensions

  • Source Measure.Events["Filler 2 Run"].Attributes["SKU Description"].Values["Grape 250ml"].Value: Only valid when processing a time period.  Returns the value/s, within the interval, of the Source Measure while event Filler 2 Run was active and where the Event Attribute SKU Description had an Attribute Value of Grape 250ml

Period Extensions

The following period extensions are available:

  • Period.Start: The UTC start time of the time/event period that the calculated measure is processing
  • Period.End: The UTC start time of the time/event period that the calculated measure is processing
  • Period.Index: Only valid when processing event periods.  Returns the index of the event period.
  • Period.Interval: Only valid when processing time periods.  The interval duration (in ms) if this is a minutely measure
  • Period.Hour: Only valid when processing time periods.  Returns the hour if this is an hourly measure.
  • Period.Shift: Only valid when processing time periods.  Returns the shift name (e.g. Night) if this is a shiftly measure
  • Period.DayOfWeek: Returns the day of week from the start of your Flow calendar’s week. For example, if your Flow calendar starts on Monday, then Monday’s DayOfWeek = 0 and Sunday’s DayOfWeek = 6
  • Period.DayOfMonth: Returns the calendar day in the current month for the time period being processed (first month = 1)
  • Period.DayOfYear: Returns the number of days since the start of the Flow calendar year for the time period being processed (first DayOfYear = 1)
  • Period.Week: Only valid when processing time periods.  Returns the week number since the start of the Flow calendar year for the time period being processed (first Week = 1) if this is a weekly measure.
  • Period.Month: Only valid when processing time periods.  Returns the month if this is a monthly measure.
  • Period.Quarter: Only valid when processing time periods.  Returns the quarter if this is a quarterly measure.
  • Period.Year: Only valid when processing time periods.  Returns the year if this is a yearly measure.
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments