Making your own calculations
To get insight into your data, you set up visualizations using various data columns, aggregation methods, and visualization properties. Often you can retrieve even more knowledge of the data by making your own calculations on it.
When you make calculations on the data, you get the results by specifying expressions that combine one or more columns with aggregation methods and/or mathematical functions. Then you can choose different ways of exposing the results:
-
Calculated columns
When you use calculated columns, the results from your expression become available as values in a new data column, which is added to the data table. The column is, like any other data column, available for selection in any visualization, and on various visualization axes, whenever the data table is used in the analysis. It can also be used in further calculations. Moreover, you can filter to the calculated values in the column, because a filter is created to represent the new column.
Generally, the calculation of the new data column is a once-only calculation. This means that once a value is calculated, it is definitive, and it will not change upon filtering. Refreshing the data leads to recalculation of the values, though.
-
Custom
expressions
When you use custom expressions, you apply your specified expression directly to the current context, for example, to an axis in a visualization. Neither a new data column nor a filter is created, and when applied to a visualization axis, no other visualizations are affected. If the visualization properties change, for example, by filtering, your custom expression re-evaluates instantly in the same way as predefined aggregation methods. This means, you can look upon the custom expression as an aggregation method created by you.
Common syntax
Even if these calculations are used in different ways, the expressions you create for what to calculate are common to both the methods. To get started with using expressions, you need to know some basic syntax rules:
- Names of data columns must
be wrapped in square brackets:
- [Sales]
- [Gender]
- Aggregation methods must
be followed by parentheses. Parentheses enclose what to be aggregated, and they
can contain more than one parameter:
- Sum([Sales])
- Max([Temperature])
- Rank([Result], "desc")
Examples of the Add calculated column and Custom expression dialogs are shown below. How to access the dialogs is described in Adding a calculated column and Applying a custom expression.
Data functions
In addition to calculated columns and custom expressions, you might also have access to data functions that can provide more functionality. See Data functions and the f(x) flyout for more information.
- Calculated columns
You can get more information about the data by making calculations based on the existing data columns in the data table. A calculation can contain mathematical as well as logical expressions. One way to expose the results from a calculation is to add them as values into a new data column. - Custom expressions
You are not limited to the pre-defined aggregation methods; you can create your own expressions and apply them to the visualization axes. The custom expressions that you create can contain mathematical as well as logical parts. The result of such an expression on an axis is immediately reflected in the visualization, just as the result of any of the pre-defined aggregation methods. - Slicing and marker concepts
When you visualize the data in a data table, the data is sliced into pieces, which are represented by markers in the visualization. Examples of markers are table cells, bar segments, pie sectors, map features, or line vertexes. Different marker attributes, like size, shape, color, or numerical values, are then used to indicate an aggregated value of the data underlying the marker. - Expression language details
If you learn how the expression language works, the creation of valid expressions will be easier. This topic attempts to explain some basic functionality of the language. - Aggregations and statistical measures
In the visualizations and various tools, calculations are performed that use aggregation and statistical measures.