Skip to main content
Interania

Creating a 2.x derived column with a 3.x event property

5votes
14updates
30views

Goal

This article shows you how to create a 2.x derived column using two values in an existing dataset to calculate the length of a user session. Then, shows you how to generate similar results by creating a 3.x custom event property.

Creating a 2.x derived column

Derived columns allow you to define new calculated columns from the data in existing (imported) data columns. You can define the derived columns with D language functions.

Derived columns must return integer (long) or decimal (double) type values. See Derived column examples for more detailed examples of using derived columns in Interana.

One of the most common ways to use derived columns is to return a calculation that uses one or more column values from a dataset. In the following example, we create a derived column to determine the session time for a user watching a movie.

To create a 2.x derived column, do the following:
  1. In Explorer, click Settings in the left navigation bar. A table of datasets appears.

WB_2.x_Settings_icon.png

  1. Click the Edit (pencil) icon for the dataset to which you'll be adding the derived column. A table of columns for the dataset appears.

WB_2.x_Edit-dataset-icon.png

  1. In the top right corner of the window, click Add Derived Column. A New Derived Column dialog appears.

WB_2.x_Add-Derived-Column.png

  1. Enter a Name for the new column, then in the text box at the bottom of the dialog enter the D language functions. The function must return integer (long) or decimal (double) type values.

In our example, we added a derived column to calculate the elapsed time for a movie watching session. We used the start_time and stop_time columns that represent when a user started and stopped playing the movie, respectively. The new derived column calculates the elapsed time, using the following syntax:

**
  * function return_elapsed_time()
  * input column(s): long start_time, long stop_time
  * output: long
  */
     
long return_elapsed_time(){
    if (stop_time == NULL || start_time == NULL){
        return -1;
    }
    return (stop_time - start_time);
}

Creating a 3.x custom event property for similar results

You can use event properties in queries to summarize, group by, and filter on re-usable properties that can be direct references to physical data columns, references to values derived from lookups, or logical expressions evaluating multiple physical columns.

This section demonstrates how to create a 3.x custom event property that you can use in a query to analyze user movie watching sessions.

To create an event property, do the following: 
  1. Select a dataset from the drop-down list in the upper left corner. Your dataset options will be for your company data. In our example, we chose the IA_MOVIES dataset.
  2. From the Explore page, click the Events icon in the left navigation bar.

icon_Events2.png

  1. Click New Event Property in the upper right corner of the window.

1.3_NewEventProperty-button.png

  1. Enter a unique Name at the top of the window to describe the property. We named our example property Movie Watching Session.
  2. In the Defined Value tab (active by default), enter a value for the property—usually the number of events associated with the property—then select the appropriate event options from the drop-down lists.

In our example, we entered a value of 1 and chose action that matches watch_movie.

WB_EventProp_DefinedValue1.png

  1. Accept "If not one of the above, then the value is empty and select a Filtered to option and respective value.

In our example, we chose timestamp that is greater than 0.

WB_EventProp_filteredto.png

  1. Click the Function tab and select event value and Filtered to options.

In our example, we chose timestamp for the event value, and filtered to a timestamp that is greater than 0.

WB_EventPropFunction_timestamp.png

  1. Click Save, then click Explore in the left navigation bar, to create a query using the Watch Movie Session event property to analyze user movie watching sessions.
  2. Make sure the dataset is still selected, then choose Show count and Filtered to options for your event property.

In our example, we chose Show count unique user actors and Filtered to Movie Watching Session (the event property we just created). In our example, we Filtered to Movie Watching Session that is greater than 0

WB_EventProp_Explore_MovieWatchinSession1.png

  1. To analyze the sessions of the various users, choose to Split by (group by in 2.x).

In our example, we chose to Split by timestamp and accepted the default Limit and Ordered by values.

WB_EventProp_SplitBy_timestamp.png

  1. Specify the Starting and Ending times. For Starting, we clicked the text field and entered 180 days ago. For Ending, we clicked the text field and entered now.
  2. Click GO. Hover the cursor over the diagram to view details for a particular user.

Our results show the frequency and duration of user movie watching sessions.

WB_DerivedColumn_EventProp_query-results.png

  • Was this article helpful?