A derived column is a computed property associated with a Dataset. In general, this property does not exist within the source data already, instead it is defined within Analytics. The definition of a Derived Column may include arbitrary computation as long as the result can be presented at the level of each record of the target dataset. This means that it may include joins with other datasets, filters, aggregations, etc.
For example, imagine that you have a Users dataset and an Events dataset. The Events dataset may have a boolean valued column Vote with values True or False. One may define a derived column on Users dataset which counts the total number of True votes per user.
A Derived Column can be used anywhere in the app that the Catalog is accessible. Its usage is similar to any other columns in the dataset.
The configuration for a Derived Column is saved within Analytics and is accessible through the Catalog. It can be utilized like any other column within the dataset through the catalog.
A derived column has the following configuration:
- Dataset - The dataset that a derived column is associated with. A given derived column is associated with exactly one dataset, which must be selected at the time of defining the derived column. The derived column appears in the catalog just like any other column of that dataset and can be used in any analysis that has access to the catalog. A derived column cannot be moved from one dataset to another.
- Name - The name of a derived column must be unique across all columns (including derived columns and cohorts) for that dataset.
- Definition - The computation for a derived column is specified using the Block Editor.
- Default Aggregation - By default, this aggregation type will be used in contexts where the derived column is used as a measure, e.g. count, sum, etc.
Create a new Derived Column
To create a new derived column,
- In the Left Navigation Panel, click + and then select Derived Column.
- Select one of the templates shown in the options - these options are to help you get started quickly, you can always change it later without losing any work. Following are the options available:
-
- Aggregation/First/Last - This allows you to create an aggregate quantity for each actor.
- Formula - This lets you write custom logic using NetScript formula language.
- Conditional on property - This type allows you to assign values based on logical conditions.
- Custom - This allows you to calculate values by composing any number of blocks.
- Conditional on Aggregate - This allows you to calculate an aggregated quantity per actor, and assign each actor to a bucket based on the value of the aggregate.
- Previous/Next value - Using this you can look up the value of the temporally previous or next event for each actor, optionally including only certain events.
- Time since - This allows you to calculate how long ago a timestamp property is.
-
- Select a Dataset for the new Derived Column in the Column of field.
- Then, select if you want the derived column to be a Measure or Attribute.
- Set the Default Aggregation.
- Using blocks, you can define the computation for your derived column.
The only constraint on the definition is that the resulting value should be at the grain of the selected dataset, or should be possible to group by the Selected dataset - and no other attribute(s).
- As you work on the definition of the Derived Column, click Run Derived Column to preview the computed values. You can also choose a different view for your visualization from the chart drop-down.
- Specify a name and description for the Derived Column.
- Click Save to save the Derived Column's definition in the Catalog.
- The new Derived Column can now be used anywhere, e.g. inside exploration templates, block editor, etc.
Types of Derived Columns
Similar to Cohorts, there are also a bunch of templates under Derived Columns that allow you to get started easily and quickly. Choosing a template is the first step in creating a new derived column and you can change this at any time without losing any work. Let's look at how each of these templates can be configured.
We use a demo app called Flix to create these sample metrics. You can also see these examples inside the app.
Aggregation/First/Last
This template allows you to calculate an aggregate quantity for each actor. As an example, let us create a derived column to calculate the sign-up date.
- Navigate to + on the left navigation panel, click Derived Column and choose Aggregation/First/Last.
- For the Column of field, choose a dataset from the drop-down. Here, we choose the Users dataset.
- Then, choose if this will be a Measure or an Attribute. Here, we choose Measure.
- Next, choose the default aggregation from the drop-down. Here, we choose avg.
- Under Blocks, choose the Aggregator for the aggregate block and also select a value from the drop-down. For the example, let us choose min as the aggregator and set event_ts as the value. Also, group the result by Users.
- Click Run Derived Column and your result will be displayed in tabular form. You can also change the chart type from the drop-down.
- Give your derived column a name and add a description (optional).
- Click Save to save all your changes.

Conditional on Property
This template allows you to assign values based on logical conditions. As an example, let us create a derived column to determine if users like/dislike the content of the website.
- Navigate to + on the left navigation panel, click Derived Column and choose Conditional on Property.
- For the Column of field, choose a dataset from the drop-down. Here, we choose the Content dataset.
- Next, choose the default aggregation from the drop-down. Here, we choose avg.
- Then, we configure the blocks. We have an If/Then/Else block in our example here - we set the condition : if vote_avg >= 7.5 then, the value is Thumbs Up else the value will be Thumbs Down.
- Click Run Derived Column and your result will be displayed in the form of a pie chart. You can also change the chart type from the drop-down.
- Give your derived column a name and add a description (optional).
- Click Save to save all your changes.

Formula
This template allows you to write custom logic using the NetScript forumla language. Follow the steps below to create a template of this type.
- Navigate to + on the left navigation panel, click Derived Column and choose Formula.
- For the Column of field, choose a dataset from the drop-down. Here, we choose the Campaigns dataset.
- Choose Attribute in the Measure or Attribute field.
- Next, choose the default aggregation from the drop-down. Here, we choose none.
- As the first step, let us enter the formula to calculate Numeric ID:
id = Data.Campaigns.id;
if not(isnull(id) or strlen(id) == 0) then to_int(id) end - Next, add a bin block to categorize the types. Choose Numeric ID as the value. Let us add 3 bins:
- Bin 1 : Social Media where x < 151.
- Bin 2 : Organic Search where 151 <= x < 501
- Bin 3 : Paid Search where x >= 501
- Enable the output toggle for this block.
- Click Run Derived Column and your result will be displayed. You can also change the chart type from the drop-down.
- Give your derived column a name and add a description (optional).
- Click Save to save all your changes.

Custom
This template allows you to calculate values by composing any number of blocks. As an example, let us create a derived column to determine Incremental Campaign Revenue.
- Navigate to + on the left navigation panel, click Derived Column and choose Custom.
- For the Column of field, choose a dataset from the drop-down. Here, we choose the Product Events dataset.
- Choose Measure in the Measure or Attribute field.
- Next, choose the default aggregation from the drop-down. Here, we choose avg.
- The next step would be adding our custom blocks. As the first step, let us add an aggregate block to calculate the number of Ads Viewed. Choose count as the aggregator and select the Product Events dataset. Let us also group the result by Campaigns.
- Next, add a formula block to calculate campaign revenue. The formula is as follows:
"Ads Viewed" * Data.Campaigns.cpm / 1000
- Click Run Derived Column and your result will be displayed. You can also change the chart type from the drop-down.
- Give your derived column a name and add a description (optional).
- Click Save to save all your changes.

Conditional on aggregate
This template allows you to calculate an aggregate quantity per actor, and assign each actor to a bucket based on the value of the aggregate.
- Navigate to + on the left navigation panel, click Derived Column and choose Conditional on aggregate.
- For the Column of field, choose a dataset from the drop-down. Here, we choose the Users dataset.
- Choose Measure in the Measure or Attribute field.
- Next, choose the default aggregation from the drop-down. Here, we choose avg.
- As an example, let us determine the number of high value users of the app. High value users are the ones that engage actively by performing actions such as making a purchase or playing content on the app.
- First, let us use the If/Then/Else block to categorize High Value Users. Set the condition as follows: where event_type in Play Content, Make Purchase then High Value User.
- Next, we add an Aggregate block to determine the number of high value users. Choose count as the aggregator and the previously created If/Then/Else block as the value.
- Click Run Derived Column and your result will be displayed. You can also change the chart type from the drop-down.
- Give your derived column a name and add a description (optional).
- Click Save to save all your changes.

Previous/Next Value
This template allows you to look up the value of the previous or next event for each actor, optionally including only certain events.
- Navigate to + on the left navigation panel, click Derived Column and choose Previous/Next Value.
- For the Column of field, choose a dataset from the drop-down. Here, we choose the Product Events dataset.
- Choose Attribute in the Measure or Attribute field.
- Next, set the default aggregation to none.
- As an example, let us consider that we want to determine the previous value of the Last Campaign Type in the Product Events time series.
- In the Previous Value Lookup block, choose previous from the drop-down and choose Product Events as the value. For 'output specific property, choose Type (a custom derived column) as the value. You can also add for each conditions if necessary - here, let us add the Users dataset.
- Click Run Derived Column and your result will be displayed. You can also change the chart type from the drop-down.
- Give your derived column a name and add a description (optional).
- Click Save to save all your changes.

Time Since
This template allows you to calculate how long ago a timestamp property is.
- Navigate to + on the left navigation panel, click Derived Column and choose Time Since.
- For the Column of field, choose a dataset from the drop-down. Here, we choose the Users dataset.
- Choose Measure in the Measure or Attribute field.
- Next, choose the default aggregation from the drop-down. Here, we choose avg.
- As an example, let us calculate the time since the last signup. In the Timestamp block, choose the Sign Up Date derived column using the drop-down.
- Then, enter the logic in the formula block. Here, we use now - Timestamp.
- Click Run Derived Column and your result will be displayed. You can also change the chart type from the drop-down.
- Give your derived column a name and add a description (optional).
- Click Save to save all your changes.

View Derived Columns
Derived Columns Page
- In the Left Navigation Panel, select the icon which says Derived Columns.
- The resulting page lists a set of templates at the top for defining new derived columns. Underneath that is a search bar to find individual derived columns by name. Below that is a paginated listing of all Derived Columns in the system, pooled across all datasets.
- Each Derived Column entry in the listing contains the following information:
- Name
- Description (if any)
- Type (this refers to the template used when defining the Derived Column).
- Updated By
- Updated At

Dataset Page
Alternatively, all derived columns for a given dataset can also be accessed from inside the dataset page by clicking on the "Derived Columns" tab there.

Please sign in to leave a comment.