# Visual Builder

### Create a new segment

To create a segment using the visual builder, follow these steps:

* **Select the type of segment you want to create** - A user segment to build a list, an event segment for all transactional use cases, or a custom segment (company, product, etc.).
* **Select a Source Entity** - Select the entity you want to use as the basis for your user segment. This could be any entity from your connected data sources, such as Customers, Orders, Products, or any other relevant entity.
* **Filter Data Based on Properties** - After selecting the source entity, you can filter the data based on the properties of that entity. For instance, you can filter customers based on their location, age, or any other relevant property.\
  \
  Icons next to each field name in the Segment Builder indicate their data type, making it easier to understand which rules apply to each field at a glance.\
  \
  You can add as many filters as you want, and combine them using the AND/OR operators.

<figure><img src="https://3204318043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxzBTp1t4OfqV67nXkVse%2Fuploads%2FR7dqInmsIbQRYVjQy0Vz%2Fimage.png?alt=media&#x26;token=a2b13abb-f683-430c-b1b8-4dbd9db6a988" alt=""><figcaption></figcaption></figure>

#### **Filter Data Based on Related Models**

You can also filter data based on related entities, such as Orders or Order Lines. For instance, you can select all customers who made at least 2 orders in the last year. You can also filter data based on entities related to related entities, such as selecting all customers who made an order in which there is an order line corresponding to a given product.\
\
\&#xNAN;*In the example below, we take all those over 20 years of age, who have already had a discount total greater than 80% of customers, and who prefer to be contacted by SMS.*

<figure><img src="https://3204318043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxzBTp1t4OfqV67nXkVse%2Fuploads%2FKgiWz1CCqq2mhwZIPoFD%2Fimage.png?alt=media&#x26;token=8fe99899-6b26-46f7-90bb-2317845228c3" alt=""><figcaption><p>You can add filters from related models by clicking on "<em>Choose a related model</em>"</p></figcaption></figure>

#### **Filter Data Based on Existing Segments**

Finally, you can filter data based on existing user segments from the same parent model. For instance, you can exclude all users from a specific segment, or include only users from a specific segment.

<figure><img src="https://3204318043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxzBTp1t4OfqV67nXkVse%2Fuploads%2FPZFuDCdXBtnr2i8w5qGz%2Fimage.png?alt=media&#x26;token=2a73eba8-deec-4c86-915f-5d271b2c9ad7" alt="" width="563"><figcaption></figcaption></figure>

#### Limit segment size

To reduce or control the size of your segment:

* Click the **Limit Segment Size** icon
* Specify the maximum segment size
* Choose **Top** or **Bottom** and select a meaningful column to sort by, such as:
  * Numeric (e.g. <kbd>revenues</kbd>)
  * Date (e.g. <kbd>last\_purchase\_date</kbd>)
  * String (e.g. <kbd>country</kbd>)
* Specify how *null* values should be handled: ignore them or place them first/last.

<figure><img src="https://3204318043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxzBTp1t4OfqV67nXkVse%2Fuploads%2F6P2FjrmGtxMAWWH0sqyi%2Fimage.png?alt=media&#x26;token=c6d190e7-e1d3-491d-bbe0-eda75d8eaa6c" alt=""><figcaption></figcaption></figure>

:bulb: *The **Top** and **Bottom** operators allow you to rank values per customer and select a subset based on that ranking. **Top** sorts values in descending order and returns the first X entries, while **Bottom** also sorts in descending order but returns the last X entries.*

This same Top/Bottom logic can be applied both in the **Segment Builder** and in **Calculated Fields** to focus on the most or least significant records per customer.

### Configure your Segment

Once your segment is ready, click on *Preview* and *Continue* to access the configure Page, then fill in the Segment Name, description, and tags.

<figure><img src="https://3204318043-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxzBTp1t4OfqV67nXkVse%2Fuploads%2FfsQXlMya9DurNAC7gB1a%2Fimage.png?alt=media&#x26;token=aced08b5-bd94-4a5a-b081-db0e7f834346" alt=""><figcaption></figcaption></figure>
