The Compare tool can be used to move cell values up or down in your dataset. Concretely it helps you look at the previous or subsequent rows relative to your current row. You can think of it as looking back or forward to see what happened before or later in your dataset.

The Compare tool is similar to a LAG function in SQL

If you’re looking for more advanced ways to do row-wise calculations check out the Difference, Multi Row, Cumulative or Running Interval tool

Configuration

The Compare tool has of two required input and one optional input.

1

Select Column(s) to Move

Select the column(s) that contains the values you would like to move vertically in your dataset

2

Input Number of Rows

Input the number of rows backward/up or forward/down that you want to fetch data from relative to your current row. Note that to look forward/down you need to input a negative value.

3

Additional Settings: Group By

This is an optional input. You can use it to segregate what you are comparing with into groups. Check out the Time Since Previous Order example below.

This configuration is similar to a PARTITION in SQL

When To Use

The Compare tool is typically used along with other tools. Generally, you can use it to understand changes or events over time:

  • It can be used with a Calculate to calculate a percentage difference
  • It can be used with a Date Difference to duration between two events
  • To find the previous SEO ranking of your website

Examples