Skip to content

Statements

Every function in this family, with its signature and examples. Each example runs as a test of the language. See Language basics for how calls, types, and operators work.

setProp

Sets a field on every row to the value of an expression; a new name adds the field. On context() it sets a context value instead; chained on insertRow() it sets a field of the inserted row from an expression that reads the current row. In a view formula it changes only the text the view shows for an existing field; the stored value stays.

setProp(name, value)
context().setProp(name, value)
insertRow().setProp(name, value)

Also callable as receiver.setProp(…), with the receiver as the first argument. Statement position only.

  • setProp("Side", prop("Side").upper()): Every row with Side in upper case
  • setProp("price", prop("price").sum()): Every group row with price set to the sum of its members
  • context().setProp("highestPrice", 0): Rows unchanged; context highestPrice is 0
  • insertRow().setProp("leg", "B").setProp("qty", 0 - prop("qty")): Every row followed by a copy whose leg is B and whose qty is the row's qty negated

unsetProp

Removes a field from every row.

unsetProp(name)

Statement position only. Operation formulas only.

  • unsetProp("expired"): Every row without the expired field

keepProps

Keeps only the named fields on every row, in that order, and removes every other field.

keepProps(name, …)

Statement position only. Operation formulas only.

  • keepProps("owner", "ISIN"): Every row with only the owner and ISIN fields

insertRow

Adds a copy of the current row, as it stands at that point, directly after it; chained .setProp(name, value) calls set fields on the copy from expressions that read the current row, and every other cell is copied. Allowed inside if() and do(); the statement never runs over the rows it inserted.

insertRow()

Statement position only. Operation formulas only.

  • insertRow().setProp("leg", "B"): Every row followed by a copy of itself with leg set to B
  • if(prop("qty") > 100, insertRow().setProp("qty", prop("qty") - 100)): Rows over 100 are followed by a copy holding the excess; the other rows pass through alone
  • do(insertRow().setProp("leg", "A"), insertRow().setProp("leg", "B"), dropRow()): Every row is replaced by two copies, leg A then leg B

splitRows

Emits one copy of every row per item of the list, the item written under name and every other field copied; an empty list drops the row. An item that is an object is carried whole and read afterwards with .prop. A row-set statement like groupBy: not allowed inside if() or do().

splitRows(list, name)

Statement position only. Operation formulas only.

  • splitRows(prop("tags"), "tag"): One row per tag, with the tag under tag and the other fields copied; a row with no tags is dropped
  • splitRows(prop("ISINs").split(";"), "ISIN"): One row per semicolon-separated ISIN
  • splitRows(prop("rows"), "item"): One row per object of the rows list, the object under item; prop("item").prop("isin") then reads one of its fields

appendRows

Adds every row of a named table after the current rows, each with the data styles that table carries. The row type afterwards is the merge of the current rows and the table's columns, so a column only one side has reads empty on the other. A row-set statement like groupBy: not allowed inside if(), do() or each().

appendRows(table)

Statement position only. Operation formulas only.

  • appendRows(inputs().prop("corrections")): The current rows, then every row of the corrections table

spreadProps

Writes one level of an object's fields as columns of the row, named by their keys. Chained .prefix(text) joins a text literal onto each name; chained .value(expression) is evaluated per field with current bound to that field's value and becomes the cell. A plain prop("x") argument removes that column after the spread. Empty adds nothing. A collision with an existing column, a non-object value, or an empty or reserved name fails. A row-set statement like groupBy: not allowed inside if(), do() or each().

spreadProps(object)

Statement position only. Operation formulas only.

  • spreadProps(prop("price")): The fields of price as columns; the price column is removed
  • spreadProps(prop("price")).prefix("p."): The fields of price as columns named p.value, p.ccy, …; the price column is removed
  • spreadProps(prop("properties")).value(ifs(current.prop("type") == "number", current.prop("number"), current)): Each property unwrapped by its type, as a column named by its key; the properties column is removed

each

Runs a statement once per item of a list, on the same row, with current bound to the item and index to its zero-based position; an empty list or an empty value runs it zero times and a value that is not a list fails the run. The body may set and unset row fields, raise an exception, write context, branch with if() and do(), and nest another each(); raiseException() needs both a field and a key there, and the key must identify the row as well as the item, because it is the whole identity of the ticket across the node. current is read-only and the list is not written back, so dropRow(), filter(), keepProps() and the row-set statements cannot run inside it.

each(list, statement)

Also callable as receiver.each(…), with the receiver as the first argument. Statement position only. Operation formulas only.

  • each(prop("legs"), if(empty(current.prop("ISIN")), raiseException("legs", concat(prop("tradeId"), ":", format(index))).setProp("message", "Leg has no ISIN"))): One ticket on the legs column per leg with no ISIN, keyed by the trade and the leg's position; every row stays in the output
  • prop("legs").each(context().setProp("lastISIN", current.prop("ISIN"))): Rows unchanged; the context value lastISIN is the ISIN of the last row's last leg

dropRow

Leaves the current row out of the output. A bare dropRow() drops every row.

dropRow()

Statement position only. Operation formulas only.

  • if(prop("expired").equal(1), dropRow()): Rows where expired is 1 are dropped

filter

With one argument, keeps the rows where the condition is true. The two-argument form is the list function.

filter(condition)

Statement position only. Operation formulas only.

  • filter(prop("expired") != 1): Rows where expired is not 1

sortBy

Stable-sorts every row by the keys, first key primary; a key is ascending unless wrapped in desc(), and empties sort last in both directions.

sortBy(key, …)

Statement position only. Operation formulas only.

  • sortBy(prop("owner"), desc(prop("price"))): Rows by owner ascending, then price descending

desc

Sorts a sortBy key descending. Valid only as a sortBy argument.

desc(key)

Operation formulas only.

  • sortBy(desc(prop("price"))): Rows by price descending

groupBy

Emits one row per key tuple in first-seen order; every field becomes the list of member values, plus __groupKey (the key values) and __groupIndices (the member indices).

groupBy(key, …)

Statement position only. Operation formulas only.

  • groupBy(prop("owner"), prop("ISIN")): One row per owner and ISIN: { __groupKey: ["zoltan", "SOMEISIN"], __groupIndices: [0, 1], owner: ["zoltan", "zoltan"], ISIN: ["SOMEISIN", "SOMEISIN"], price: [3, 6] }

do

Runs statements left to right on the same row.

do(statement, …)

Statement position only.

  • if(prop("owner").empty(), do(raiseException().setProp("message", "Owner is missing"), dropRow())): Rows without an owner raise an exception and are dropped

if

With statement branches, runs the first branch on rows where the condition is true and the second, when present, on the others; rows without a branch pass through.

if(condition, statement, statement)

Statement position only.

  • if(prop("Created by").equal("buy"), setProp("Created by", "BUY"), setProp("Created by", "SELL")): Created by is "BUY" on buy rows and "SELL" on the others