Saltar al contenido principal

Reduce

Category: Transform
Node id: reduce

Reduces an array to a single value using sum, product, concatenation, first, or last operations

What it does​

  • Five reduction types: sum, product, concat, first, last
  • Object-field and direct-value reduction modes
  • Configurable separator for string concatenation
  • Null/missing value handling during reduction

Use cases​

  • Sum up billing amounts across claim line items
  • Concatenate diagnostic text from multiple encounters
  • Extract the first or last item from an ordered result set

Runtime​

  • Performance tier: fast

Input ports​

NameTypeRequiredDescription
datajsonYesArray of values or objects to reduce

Output ports​

NameTypeRequiredDescription
resultanyNoReduced result value (scalar for sum/product/concat/first/last)
foundbooleanNoWhether a value was found (relevant for first/last types)
successbooleanNoWhether the reduction completed without error

Settings​

Basic​

SettingNameTypeRequiredDefaultAllowed valuesDescription
Reduce Typereduce_typeenumYessumsum, product, concat, first, lastType of reduction operation
FieldfieldstringNoField name to reduce when items are objects (leave empty for direct value reduction)

Advanced​

SettingNameTypeRequiredDefaultAllowed valuesDescription
SeparatorseparatorstringNo""Separator for concat reduction

Errors​

CodeDescription
UNSUPPORTED_REDUCE_TYPEThe specified reduce_type is not recognized
INVALID_DATAInput data is not a valid array
EMPTY_ARRAYCannot reduce an empty array (for first/last)

Runtime notes​

  • Output also includes count (number of values reduced) and reduce_type echo; for concat it adds separator
  • When field is set, the node extracts that field from each object; when empty, array elements are used directly
  • Non-numeric values are silently skipped for sum/product; count reflects only successfully converted values
  • first/last on an empty array returns result=null with found=false

See Build any workflow for how to put nodes together and Ports, types and data flow for how port types connect.

¿Algo no está claro? Envíe sus comentarios sobre la documentación por correo electrónico..