Use derived columns to define new calculated columns after data has been imported. You can define the derived columns with D language functions, and they must return integer (long) or decimal (double) type values.
This document provides a detailed overview of the language features available when coding a derived column function.
Derived Columns must return an Integer, String, or Decimal
Derived columns must return an integer (technically a long), string, or decimal (double) value.
Derived Columns use the D programming language
The D programming language is a compiled language with a feel similar to C/C++. When coding a D function for use in an Interana derived column, keep in mind the following limitations:
- Your function must comply with the @safe annotation (statically checked to exhibit no possibility of undefined behavior)
- Your function must comply with the pure keyword (cannot access global or static, mutable state except through its arguments)
For performance and security reasons, many standard D library functions are not available.
Available D Libraries
We do not currently support any D libraries.
Tips for working with derived columns
- You must escape "." in the column name or it will not compile. You can either rename the column or surround these columns with the
- Derived columns reference the friendly column name. If you change that name after creating the derived column, the derived column will no longer work.
- Avoid using D language reserved characters in column names. For example, Derived Columns cannot reference columns named "c", a reserved character in D. See the D language Lexical topic for more information.
Interana built-in functions that operate on columns
Within your derived column, you can reference the following custom functions:
|Column type||Function / variable||Notes|
Given a column name (as a quoted string), returns its integer value for the current row.
Typically you can make a direct, unquoted reference to any column name to get its value, but in some cases the column name has a special character (like a .). Use this function in those cases.
||Tests the value of a string column against a regular expression (returns 1 if match, else 0).|
||Returns the number of elements in the int_set or string_set column (for this particular row).|
||Tests all values of an int_set column for the specified integer value. Returns 1 if match, else 0.|
||Tests all values of a string_set column against a regular expression. Returns 1 if match, else 0.|
Within your D function, you can reference Interana columns of type:
You can also reference columns containing "." characters. You must surround these columns with the
Referencing lookup columns
As of version 2.18, you can reference a lookup column when defining a derived column. You can use the columns in the lookup table as normal columns, or use the
lc() function to get the value from that column.
Use the syntax
lc("column_name") to reference a lookup column.
Interana does not support the following references:
- time columns (for example, of type milli_time)
- named expressions, including cohorts, sessions, metrics, funnels
- other derived columns
set_size and get_item functions
Note that when you import set columns to Interana, the import process preserves the order of items in the column and does not de-duplicate items in the set. Interana also does not distinguish between null and empty data.
||Returns the number of elements in a set column (int_set, string_set)|
||Returns the element from the set at position