Skip to main content
Skip table of contents

What's New in Formula

New Functions

resampleHold()

This function improves performance for calculations that use infrequently updating signals. It avoids problems with configuring large max interpolations by resampling a step signal more frequently. More background is in Optimizing for Infrequently Updating Data

concat(), distinct()

These new functions aid in aggregating string capsule properties. For example, if you want the weekly list of material codes used during $batches, you can use

CODE
weeks().setProperty('materialCodes', $batches, 'materialCode', 
  $group -> $group.concat(','))

This creates a weekly condition with the property materialCodes that is the concatenated list of materialCode properties, joined by a comma, occurring during capsules from $batches.

The last parameter is a lambda expression that reduces the group of extracted property values to a single value. Lambda expressions might look like complicated syntax, but they can be powerful expressions.

The $group can be any variable name you want, it just needs to be unique in your formula expression. In this context of setProperty(), it’s the group of values that occur in the measured condition during the bounding condition. The lambda reduces that group to a single value.

Other group functions that can work with groups to create that reduced value:

  • $group.concat([joinString], [prefixString], [suffixString]) Each of the optional parameters defaults to the empty string

  • $group.distinct() Discard any duplicates in the group. String uniqueness is case-sensitive.

  • $group.sort([direction]) Sort the members of the group. Numbers sort numerically and strings sort alphabetically (case sensitive). By default, the direction is "asc" for ascending.

  • $group.keep($scalar -> $scalar.contains('substring')) Another lambda expression that returns true if the value should be retained.

The power of the lambda is in the chaining these:

CODE
$group -> $group.keep($v -> $v.contains('xyz').distinct().sort().concat(',')

This creates the distinct, sorted, and comma-joined list of properties.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.