# Transform

Reshape what one step produced into what the next one needs. There is no separate transform step: a step’s Input mapping does it, with the same expressions conditions use.

Data step, Transform:

- Written as: `Input mapping`
- Reads: `{ Field: Read.Lines }`
- Nodes: `Filter, Map, Length, Add…`

## Inputs

- `<field>: { Field: path }` (expression): Reads a value: Trigger for the request, or a step’s name for its output, then its fields.
- `<field>: <literal>` (literal): A number, string, true or false, list or object, taken as written.
- `<field>: { <node>: … }` (expression): Any expression node below, evaluated when the step runs.

## Outputs

- `<mapped input>` (object): The object the mapping builds, which the step is called with. A path that resolves to nothing leaves its field out.

## Expression nodes

| Node | Arguments | Gives |
| --- | --- | --- |
| `Map` | `Over, As, Body` | Each item turned into a new value |
| `Filter` | `Over, As, When` | The items the condition holds for |
| `Aggregate` | `Over, As, Into, Body` | One value folded from every item |
| `Length` | `Of` | How many items or characters |
| `Sort` | `Over, By, Descending` | The items in order |
| `Unique` | `Over` | The items without repeats |
| `Range` | `From, To` | A list of numbers |
| `Add, Subtract, Multiply, Divide, Modulo` | `Left, Right` | A number |
| `Concat` | `Left, Right` | Two strings joined |
| `If` | `When, Then, Else` | One of two values |
| `Let` | `Name, Value, In` | A value named for the expression inside it |
| `FunctionCall` | `Function, Args` | What a declared function returns |

## Example

```yaml
- ExecuteTool: Notify
  Operations: [PostMessage]
  Input:
    channel: finance
    overdue:
      Filter:
        Over: { Field: Read.Invoices }
        As: Invoice
        When: { GreaterThan: { Field: Invoice.DaysLate, Value: 30 } }
    count:
      Length:
        Of: { Field: Read.Invoices }
```

## Reusing an expression

Declare an expression once under `Functions` and call it anywhere with `FunctionCall`. Its parameters are its only names: the body reads them, not the run’s values.

```yaml
Functions:
  - Name: OverLimit
    Parameters: [Amount, Limit]
    Body:
      GreaterThan:
        Field: Amount
        Value: { Field: Limit }

Steps:
  - Branch: Check
    Cases:
      - When:
          FunctionCall:
            Function: OverLimit
            Args:
              Amount: { Field: Read.Amount }
              Limit: 500
        Then:
          - Wait: Approve
            Operation: Clarification
            Question: This refund is over the limit. Approve it?
```

> **Bounded and repeatable**
> An expression gives the same value every time it reads the same values, and it cannot loop forever: every evaluation stops at the deployment’s expression ceiling, 1,000 nodes by default. A model step is the place for work that needs judgment.

## Related steps

- [If](/docs/workflows/steps/if/): The same expressions as conditions.
- [Call a tool](/docs/workflows/steps/call-a-tool/): The step whose Input is most often mapped.
- [YAML reference](/docs/workflows/yaml/): Every field the file accepts.
