You can create custom metrics and attributes to use in your query or other calculated elements. You create these elements in the formula editor.
This article helps you navigate the formula editor, and identify the different options that help you create formulas.
For help creating formulas and functions, see Formula writing resources.
Using the formula editor
The formula editor is where you enter or edit your formulas and functions. You access the formula editor from the calculations menu () when you create certain types of calculated metrics and attributes, for example, Standard calculated metric.
As you write formulas, the formula editor suggests auto-complete matches to what you are typing. Everything entered in the formula editor is color-coded.
If your formula is incorrect, an error icon () will appear next to the line containing the error. Information describing the error will appear at the top of the box.
Adding attributes and metrics to your formula
In Explore, you can add attributes and metrics to your formula. Unlike result manipulations, these elements do not need to be currently added to your query, and can include calculated metrics and attributes.
- Under Fields, Click Select a field.
- Select a metric or attribute from the drop-down list.
The Fields drop-down list is useful for viewing all the available elements in a dataset. For datasets with many metrics and attributes, you can use the search bar or Explore's auto-complete.
You can also type in metrics and attributes. Make sure to either select Explore's auto-complete match, or replicate the exact formatting. Metrics must be written with the aggregator first in all caps, and then the metric name in parentheses. Attribute names must be entered inside of brackets. Calculations will not process incorrect formatting.
Adding functions to your formula
When you click Add, you will be redirected to the Functions window. This window is useful if you are not sure which function is applicable to the calculated element you want to create. All functions in the Functions window contain a brief explanation of the functions purpose. For a full list of functions, see Formula writing resources.
If you are looking for a specific function, you can search for functions or filter by function type.
- In the Functions window, click Filter.
- Type in a category or select a category from the drop-down list.
- Click the x next to the category name to remove the filter.
When you create calculated metrics or attributes, there are additional options you can select from.
You can apply the following option to your calculated metric or attribute:
- Compute separately: If your formula will affect your other metrics and attributes. Selecting Compute separately will create a separate query for the calculation and not influence the existing elements.