Global values

Global values are used to compute various summary statistics for specified fields. These summary values can be accessed anywhere within the flow. Global values are similar to flow parameters in that they are accessed by name through the flow. They're different from flow parameters in that the associated values are updated automatically when a Set Globals node is run, rather than being assigned by scripting. The global values for a flow are accessed by calling the flow's getGlobalValues() method.

The GlobalValues object defines the functions that are shown in the following table.

Table 1. Functions that are defined by the GlobalValues object
Method Return type Description
g.fieldNameIterator() Iterator Returns an iterator for each field name with at least one global value.
g.getValue(type, fieldName) Object Returns the global value for the specified type and field name, or None if no value can be located. The returned value is generally expected to be a number, although future functionality may return different value types.
g.getValues(fieldName) Map Returns a map containing the known entries for the specified field name, or None if there are no existing entries for the field.

GlobalValues.Type defines the type of summary statistics that are available. The following summary statistics are available:

  • MAX: the maximum value of the field.
  • MEAN: the mean value of the field.
  • MIN: the minimum value of the field.
  • STDDEV: the standard deviation of the field.
  • SUM: the sum of the values in the field.

For example, the following script accesses the mean value of the "income" field, which is computed by a Set Globals node:

import modeler.api

globals =
mean_income = globals.getValue(modeler.api.GlobalValues.Type.MEAN, "income")