---
title: Advanced segment builder
description: "Use Amplitude's advanced segment builder to combine user, session, and event scopes in containers and to filter on ordered event sequences with THEN and WITHIN."
product: analytics
lang: en
last_updated: 2026-10-29
token_estimate: 687
---
# Advanced segment builder

> For AI agents: a documentation index is available at [/docs/llms.txt](/docs/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

The advanced segment builder groups segment conditions into containers, each with a user, session, or event scope, and filters on events that happen in a specific order. Use it to apply complex logic, filter across multiple scopes in one segment, or view a segment's conditions as a hierarchy. For segments that don't need containers or sequences, build them directly in a chart's Segmentation Module.

You can use the advanced segment builder in Event Segmentation, Funnels, Data Tables, Metrics Explorer, and Sessions charts. For an overview of user, session, and event scope, refer to [About segments](https://amplitude.com/docs/analytics/segments/about-segments#segment-scopes).

## Open the advanced segment builder

Open the builder in any of these ways:

- In the Segmentation Module, click **+ Filter > Open Advanced Builder**.
- In the Segmentation Module, click the pencil icon on a segment.
- Below the Segmentation Module, click **+ Add Segment > Open Advanced Builder**.
- In Object Management, click **Create New > Saved Segment**.

## Set the parent scope

The parent scope is the outer container of the segment. You can add containers at the same scope or a lower scope inside it.

To change the parent scope, select **Users**, **Sessions**, or **Events** in the _Filter \[scope\] who match these conditions_ section of the builder.

Join multiple containers with AND, OR, or THEN. The following example returns users who had sessions that met one of two sets of conditions.

![A user-scoped parent container with two session containers joined by OR](https://amplitude.com/docs/images/analytics/segments-parent-scope.png)

## Combine scopes

Combine containers of different scopes with AND or OR logic.

![A user-scoped segment with a session container joined by AND to an event container for Complete Purchase](https://amplitude.com/docs/images/analytics/segments-mixed-scopes.png)

## Filter on event sequences

Sequencing filters users or sessions by events that happen in a specific order:

- **THEN** requires one condition to happen after another.
- **WITHIN** requires the sequence to complete within a set number of events.

The following example returns sessions where a user viewed the `/` page, then viewed the `/search` page within one `Page Viewed` event.

![A session container with two Page Viewed conditions joined by THEN, within 1 Page Viewed event](https://amplitude.com/docs/images/analytics/segments-sequential.png)

Event containers don't support THEN because Amplitude can't evaluate a single event as a sequence.

