> ## Documentation Index
> Fetch the complete documentation index at: https://synthetiq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# conditional

> Conditionally execute downstream steps based on data or variables

Execute downstream steps only when a condition is met. When a branch evaluates to false, all steps that depend on its output table are skipped.

```typescript theme={null}
{
  branch: {
    sql: "SELECT COUNT(*) > 0 FROM raw_orders WHERE status = 'pending'",
  },
  outputTable: "has_pending_orders",
}
```

| Field         | Required | Description                                                                                                                                                                                                         |
| ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `outputTable` | Yes      | Name of the table this step produces                                                                                                                                                                                |
| `condition`   | No       | A [template variable](/docs/platform-docs/workflows-framework/variables) to evaluate. Truthy values (`true`, non-empty strings, non-zero numbers) execute the branch. Falsy values (`false`, `""`, `0`, `null`) skip it. |
| `sql`         | No       | SQL query that returns a single value. Truthy results execute the branch.                                                                                                                                           |

One of `condition` or `sql` must be specified, but not both.

## Dependency graph

Branch steps produce an output table like any other step. Steps that reference the branch's output table only execute if the branch condition is met:

```typescript theme={null}
steps: [
  { service: "shopify", operation: "listOrders", ..., outputTable: "raw_orders" },

  {
    branch: {
      sql: "SELECT COUNT(*) > 1000 FROM raw_orders",
    },
    outputTable: "large_dataset_flag",
  },

  {
    sql: "SELECT ... FROM raw_orders WHERE ...",
    outputTable: "filtered_orders",
    dependsOn: ["large_dataset_flag"],
  },
]
```

If `raw_orders` has fewer than 1,000 rows, the `filtered_orders` step is skipped entirely.

## Validation

| Check                                                                                                         |
| ------------------------------------------------------------------------------------------------------------- |
| Only one of `condition` or `sql` can be specified                                                             |
| SQL conditions are validated the same as [sql steps](/docs/platform-docs/workflows-framework/steps/sql#validation) |
