Sequential Comparison Calculated Column
This topic outlines the purpose and uses of the Sequential Comparison calculated column available in the Manage Data > Data Warehouse page. Below is an explanation of what it does, followed by an example and the mechanics of creating it.
Explanation
The Sequential Comparison column type: finds the difference between consecutive events. The most common type of Sequential Comparison column is the Seconds since previous order column. There are three inputs needed for this column:
Event Owner: This input determines the entity for which rows are grouped. For example, in theSeconds since previous ordercolumn, the event owner is the customer, because you want to find the number of seconds since the previous order of the same customer.Event Date: This input enforces the sequence of events. In the cases ofSeconds since previous order, the column containing the timestamp of the order should be theEvent Date. This input is always a timestamp.Value to Compare: This input is the actual value to be compared. It subtracts the previous row’s value from the current row’s value. Hence, a column finding the time difference between successive orders of a customer is calledSeconds since previous order. This input does not have to be a timestamp. A non-timestamp example is to find the difference in order value between successive orders of a customer.
Example
event_idowner_idtimestampSeconds since owner's previous event12345In the above example, Seconds since owner's previous event is the Sequential Comparison calculated column. For the owner_id = A, it first identifies a sequence based on the timestamp column, and then subtracts the previous event’s timestamp from the current event’s timestamp. In the third row in the table – the second row for owner_id A – the value of Seconds since owner's previous event is the number of seconds between ‘2015-01-01 02:00’ and ‘2015-01-01 00:00:00’. This difference equals two hours = 7200 seconds.
For this calculated column type, the row corresponding to the owner’s first event has a NULL value.
Mechanics
To create an Event Number column:
-
Navigate to the Manage Data > Data Warehouse page.
-
Navigate to the table on which you want to create this column.
-
Click Create New Column in the upper-right corner.
-
Select
Same Tableas theDefinition Type(if the columns that you want to compare are not on the same table you may need to relocate them). -
Select
SEQUENTIAL_COMPARISONas theColumn Definition Equation. -
Choose the inputs, as explained above:
Event OwnerEvent DateValue to Compare
-
Filters can also be added to exclude rows from being considered. The excluded rows have a
NULLvalue for this column. -
Provide a name for the column at the top of the page and click Save.
-
The column is available to use immediately.