Using table calculations
Use table calculations to create ad hoc metrics to use in your visualizations.
Table calculations are similar to spreadsheet formulas. They are displayed as green columns in a data table, rather than blue columns (dimensions) or orange columns (measures).
You can use table calculations to perform mathematical, logical, text-based, and date-based calculations on the dimensions, measures, and other table calculations in your query.
Keep the following considerations in mind as you use table calculations:
- All of the fields that you use in your table calculations must be part of your initial query.
- Formulas must be in lowercase.
- Table calculations only operate over rows that are returned in your query. If there is a 500 row limit, the 501st row will not be considered.
- You must always use leading zeros for decimals less than 1. For example, 0.95 will work, but .95 will cause an error.
- Table calculations are automatically displayed in visualizations.
- You can sort table
calculations just as you would a dimension or measure, with the following
differences:
- Table calculations are created after the data is retrieved from your data sources, which means that when you sort a table calculation, you can only sort the data that is already displayed.
- If a table calculation applies to multiple rows in the same column, sorting the table calculation would change the results and is therefore disabled. For example, if a table calculation includes the offset() function, sorting the table calculation would change the row being referred to, which is not permitted.