Skip to content

Branch

The "branch" declaration forks the current input into a separate transform pipeline. The input can be defined in the view or inherited from an ancestor. Filters and row mutations in the branch affect that pipeline only; the main pipeline continues with its original rows. This is useful for calculating summaries or publishing "values" without removing the data used by marks.

Parameters

description

Type: string

A description of the transform step. Can be used for documentation and agent context.

transform Required

Type: array

Side transforms in the same parameter scope as the owning view.

Tapping the current input

This branch publishes selected positions while the main pipeline retains all rows and calculates doubled:

{
  "transform": [
    {
      "type": "branch",
      "transform": [
        { "type": "filter", "expr": "datum.keep" },
        { "type": "values", "field": "position", "param": "positions" }
      ]
    },
    { "type": "formula", "expr": "datum.score * 2", "as": "doubled" }
  ]
}

A branch shares the declaring view's parameter scope. It does not introduce another view or lexical scope. Its output names must be unique in that scope. An explicit "collect" can sort the branch's rows or cache them for replay when a filter depends on an ordinary parameter.

Example

The Values example calculates cluster gaps from metadata in a branch while retaining every heatmap cell in the main path.