# Selector and numeric

You can use the on the fly functionality to define a pattern match aggregation on a:

- a **selector and value variable** together
- a [selector variable](<https://help.apteco.com/en/faststats/expressions/aggregations-on-the-fly/pattern-match/index.md>) alone
- a [value (numeric or currency) variable](<https://help.apteco.com/en/faststats/expressions/aggregations-on-the-fly/pattern-match/numeric/index.md>) alone

The following example demonstrates how you can carry out powerful and insightful pattern match analysis using a selector and numeric variable together.

## Scenario

### Find people who have been to Australia, then the United States, and then Greece, where the cost of the Australian booking is greater than £1000, with a more than 10% increase in the cost of the US booking and then the Greece booking

To get started:

1. Open a new expression window and click on the **Add Aggregation** button and then on the tab entitled **Frequency(Bookings)** that opens up.
2. In the Type drop down select **Pattern Match**.
3. Set the Grouping Table to **People** and Transactional Table to **Bookings**.
4. Drag the **Booking Date** variable onto the **Order records by** drop-box and leave the **From** as **Earliest to Latest**
5. Select **Pattern Match Selector Variable** then drag **Destination** onto the pattern match variable drop-box.
6. Leave the **Pattern Match Type** as **Manual** and click **Set pattern**.
7. Define your pattern match sequence as follows and click **OK**:
8. Select **Pattern Match Numeric Variable** then drag **Cost** onto the pattern numeric variable drop-box.
9. Leave the **Pattern Match Type** as **Manual** and click **Set pattern**.
10. Define your pattern match sequence as follows and click **OK**:

    > **Note**
    >
    > The pattern name of the numeric value must exactly match that used for the selector.
11. From the **Return the** drop-down, select **Pattern Name**.

    > **Note**
    >
    > For more on the pattern elements you can include when creating sequences on selector and numeric variables see [Sequence Analysis Wizard](<https://help.apteco.com/en/faststats/wizards-and-virtual-variables/sequence-analysis-wizard/index.md>).
12. Name the expression - e.g. AusUSAGreece\_PatternName

You can now use the pattern match expression to continue your analysis. For example:

1. Drag and drop the expression onto a new People level selection and enter the pattern **Aus-USA-Greece**.

   Building the selection returns a count of 7 people who currently match the defined pattern
2. Drop a data grid onto the selection and add **Booking Date**, **Destination** and **Cost**.
3. Group by **Person URN** and build.
4. Sort into ascending order by booking date.

You can see that each person satisfies the pattern by:

- Having a sequence of bookings that is Australia followed by the United States and then Greece;
- The cost of the Australian booking being more than £1000;
- The cost of the US booking being more than 10% higher than the Australian booking;
- The cost of the Greece booking being more than 10% higher than the US booking,
