# Rank transaction

## Scenario

Rank a person's holiday bookings by Booking Date (Latest to Earliest)

[![](<https://help.apteco.com/assets/images/faststats/expressions/aggregations-on-the-fly/rank-transaction/Aggregations-on-the-fly-Q118-(12).png>)](<https://help.apteco.com/assets/images/faststats/expressions/aggregations-on-the-fly/rank-transaction/Aggregations-on-the-fly-Q118-(12).png>)

- Open a new **Expression** window from **Toolbox** ribbon bar and set the table level to **Bookings**
- Click on the [![](<https://help.apteco.com/assets/images/faststats/Aggregations-on-the-fly-Q417-(11).png>)](<https://help.apteco.com/assets/images/faststats/Aggregations-on-the-fly-Q417-(11).png>) **Add Aggregation** button
- Click on the tab entitled **Frequency(Bookings)** and change **Type** box to show **Rank Transaction**

  > **Note**
  >
  > The auto-naming feature will populate the Name box until you change it.
- Leave the Grouping Table as **People** and Transactional Table as **Bookings**
- Drag the **Booking Date** variable onto the **Drop your ordering variable here** drop box and change the order display to **Latest to Earliest**
- Click the **Build** button to see a preview of the results

  [![](<https://help.apteco.com/assets/images/faststats/expressions/aggregations-on-the-fly/rank-transaction/Aggregations-on-the-fly-Q420-(1).png>)](<https://help.apteco.com/assets/images/faststats/expressions/aggregations-on-the-fly/rank-transaction/Aggregations-on-the-fly-Q420-(1).png>)

A **Data Grid** can be used to validate the results:

[![](<https://help.apteco.com/assets/images/faststats/expressions/aggregations-on-the-fly/rank-transaction/Aggregations-on-the-fly-Q417-(15).png>)](<https://help.apteco.com/assets/images/faststats/expressions/aggregations-on-the-fly/rank-transaction/Aggregations-on-the-fly-Q417-(15).png>)

The example above demonstrates how you can take an ordered set of transactions and rank them from 1 to N. There is also the option to **Group by** and add a grouping selector variable and the ranks to be calculated within each grouping category. This allows you to identify, for example, "the first / last N transactions to each booking Destination" or "the most expensive transaction to each booking Destination".
