|
Table calculations provide a powerful way to derive new data within a data visualization without altering the underlying dataset. These calculations are performed on the result set after all other SQL calculations have been executed, allowing for dynamic and flexible analysis directly within report builder's interface. Table calculations are custom calculations created directly within report builder to perform calculations on data returned by a query. These calculations create the ability to compute new fields, metrics, or aggregations based on existing data in the result set, providing a high degree of flexibility for analysis.
When writing custom calculations using this tool, a wide range of mathematical, statistical, and conditional functions may be defined, and there can be a specific context entered for how these calculations may be performed. For example, calculations can be applied to a specific dimension, dimension group, or across entire data sets. Table calculations may help with viewing various analytical tasks such as year-over-year comparisons and trend analysis assisting in future decision making.
A window will appear to create a table calculation. A type of calculation must be selected to apply to the report. Below are the types of calculations that are selectable:
Calculation Type | Definition |
---|---|
% of column | The row value divided by the sum of values in the column. (Only includes values in the data table when row limit has been reached). |
% of previous row | Current row’s value divided by the value of the row below. |
% change from previous row | Difference between the current row’s value and value of the row below, divided by the value of the row below. |
Rank of Column | Rank of row’s value among all values in the column (Only includes values in the data table when the row limit has been reached). |
Running column total | Cumulative sum of this row and all previous rows in the column. |
Custom expression | Add a custom expression, or edit an existing expression in the free field text box. |
For more information on using table calculations in Report Builder, see these external sources: Using Table Calculations and Looker Functions and Operators. |
For reporting API users: the way that the row limit is set varies slightly by endpoint:
reporting/report-schedules/*
endpoints: the parameter is send_all_results.
reporting/run-query
and /reporting/run-saved-report
endpoints: the parameter is limit.
Table calculations will be returned when there is a row limit applied to the query, whether that is set via the API at query submission time (via the |
Other Considerations
The following are smaller considerations to keep in mind when creating a table calculation:
percentile
or median
. This is because table calculations calculate totals using the values in the Total row, not by using the values in the data column.