Compare
Move values vertically
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.
Select Column(s) to Move
Select the column(s) that contains the values you would like to move vertically in your dataset
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.
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
Calculate Percentage Difference
Calculate Percentage Difference
I want to calculate the month-on-month sales growth
Time Since Previous Order
Time Since Previous Order
I want to calculate the average time (measure in days) between my customers making repeat orders
Note that we are fetching one row upward/backwards in the dataset within the customerID group. So while the values might move visually more than one row, it is moving one row “inside” the group - customerID