Use these examples when creating calculated measurements to easily create fields. Each example contains an explanation with a code sample.
Required Editions
| Available in: Intelligence Reports Advanced |
Tips:
- For Equals use ‘==’
- For Or use ‘||’
- For And use ‘&&’
- For “not” use ‘!’ (expression)
Calculate Your Own Rate
You want to calculate the key performance indicators (KPIs) in Intelligence Reports for Engagement using a different formula. For example, the Email Open Rate is calculated by dividing the Unique Email Opens by the Email Deliveries. With calculated measurements, create another version of the Email Open Rate that uses the Email Sends as the denominator instead of the Email Deliveries.
Formula
IFERROR(someExpression, number)
Description
Returns someExpression if it’s a valid number, otherwise it returns a number.
Example
To create Email Open Rate:
IFERROR([Email_Unique_Opens]/[Email_Sends], 0)
Original Data Set
| Campaign | Email Send | Email Unique Opens |
|---|---|---|
| Welcome | 50 | 35 |
| Birthday | 65 | 10 |
| Promotion | 70 | 55 |
Results with Calculated Measurement
| Campaign | Open Rate (Calculated) |
|---|---|
| Welcome | 70% |
| Birthday | 15% |
| Promotion | 78% |
Calculate Filtered Metrics
Create a measurement that’s filtered based on a condition. For example, create a dedicated measurement for clicks from each device for Mobile clicks, and Web clicks.
Formula
IF(condition,resultIfTrue,resultIfFalse)
Description
Returns the second argument, if the first argument is true, and the third argument if otherwise.
Formula
LOWER(text)
Description
Converts all uppercase letters in a text string to lowercase.
Examples
Desktop clicks metric: IF(Lower([Email_Device_Type])== desktop,[Email_Unique_Clicks],0)
Mobile clicks metric: IF(Lower([Email_Device_Type]) == 'mobile',[Email_Unique_Clicks],0)
Original Data Set
| Campaign | Email Device Type | Email Unique Clicks |
|---|---|---|
| Welcome | Mobile | 40 |
| Welcome | Desktop | 55 |
| Birthday | Desktop | 35 |
| Birthday | Desktop | 70 |
| Birthday | Mobile | 30 |
Results with Calculated Measurement
| Campaign | Mobile Clicks | Desktop Clicks |
|---|---|---|
| Welcome | 40 | 55 |
| Birthday | 30 | 105 |
Calculate a Share Metric
You want to calculate the share of unique clicks by any dimension. For example, the share of unique clicks by Email Link Alias.
Formula
SUM(metric, [groupByDims])
Description
Computes the sum of the given metric grouped by the supplied dimensions (optional).
Example
To calculate the share of email unique clicks
[Email_Unique_Clicks]/SUM([Email_Unique_Clicks])
You can then use this metric alongside any relevant dimension, and get the share of the metric according to that dimension.
Original Data Set
| Email Link Alias | Email Unique Clicks |
|---|---|
| Header | 30 |
| Fill in form | 50 |
| Go to site | 25 |
Results with Calculated Measurement
| Email Link Alias | Share of Clicks (Calculated) |
|---|---|
| Header | 28% |
| Fill in form | 47% |
| Go to site | 23% |
Count Distinct Use Case
You want to count the number of unique Email Content Names.
Formula
COUNTDISTINCT([dimensions], [groupByDims])
Description
Returns the number of unique appearances of dimension value combinations, within the supplied context dimensions. If no groupBy dimensions are supplied, the row context is used by default.
Example
COUNTDISTINCT([Email_Content_Name])+[Email_Sends]-[Email_Sends]
Original Data Set
| Campaign | Email Content Name |
|---|---|
| Welcome | A_Welcome_AMER |
| Welcome | A_Welcome_EMEA |
| Birthday | A_Birthday_EMEA |
| Birthday | B_Birthday_AMER |
| Birthday | B_Birthday_APAC |
Results with Calculated Measurement
| Campaign | Unique Email Content Names (Calculated) |
|---|---|
| Welcome | 2 |
| Birthday | 3 |