Calculated fields can be formed from custom calculations, using the calculated field editor with your data source. Calculations can be formed as an aggregated calculation or non-aggregated (row-level). Calculated fields are particularly useful when your data source does not contain all the values you need for your analysis.
Calculated Fields can include:
- Fields - Contains all the data source fields and calculated fields
- Functions - Use to create a formula, which is available from the dropdown-menu (Number, String, Date, Type Conversion, Logical, Aggregate, User, Table Calculation, Spatial)
- Operators - Standard Operations; Addition (+), subtraction (-), multiplication (*), modulo (%), division (/); Comparisions (E.g. ==,=,>,<,>=,<=,!=,<>); and logical (E.g. AND, OR, NOT, IF)
An example using a logical operator using IF statement:
If we wanted to find out (when aggregated) how many products reached sales over 100,000
For an introduction to IF statments read this blog by the Flerlage Twins A Beginner’s Guide to IF Statements in Tableau
Using a similar example we can see how this would look when non-aggregaed (row-level):
How many sales within each product are above 1000?
- Parameters - Placeholder variables that can be inserted into calculations to replace constant values
For more information about parameters read this blog by Tanya Fischer Creating an easy Parameter in Tableau
- Comments - Type two forward slash characters (//) into the formula pane to annotate your calculations, the editor will go back to normal on the next line
- Syntax error: when creating a custom calculated field it's very important that your syntax is correct or your calculated field will not work - by hovering bottom left corner Tableau explains why there is a syntax error
Custom Calculated fields are very versatile and allow you to gain more control of your data, especially when you create Level of Detain expressions (LOD) in the formula editor, which allows you to specify the granularity for an aggregation.
Adam Ratcliffe wrote an introduction to LODs - Level of Detail Calculations - The Basics
Another way calculated fields can be generated is through table calculation within Tableau (calculations applied after the data is returned). Some predefined table calculations are available as quick table calculations, but you can also specify the components of the formula.
See Andy Krebel's blog explains Table Calculations - Table Calculations Overview
Calculated fields can be a little scary at first, but with practice and familiarity it's a very useful skill to have to help with your analysis.