You can create calculated metrics and attributes to use in your query or in other calculated elements. These calculated elements are created using a unique formula language in the Formula writing window.
This article instructs you on navigating the Formula writing window and identifying the different options available for creating your formulas. For help creating formulas and functions, see Formula writing resources.
Using the Formula Editor
The most important component in the Formula writing window is the Formula Editor. The Formula Editor is where you will enter or edit your formulas and functions.
When writing formulas, the formula engine will suggest 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 on your query and can include calculated metrics and attributes.
- Click Select a field underneath Fields.
- Select your metric or attribute from the drop-down list.
Any attribute you enter will be inserted in brackets  and any metric will be inserted in parentheses ().
The Fields drop-down list is useful for viewing all the available elements in a dataset. For datasets with several metrics and attributes, it might be better to use the search bar or Explore's auto-complete.
You also have the option of manually typing in metrics and attributes. Please ensure you 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. The Functions 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. There are fourteen function categories you can filter by.
- Click the Filter button at the upper left of the Functions window.
- 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 are creating calculated metrics or attributes, there are some 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 SQL query for the calculation and not influence the existing elements.