Why Calculations are Useful for Your Tableau Visualizations - dummies

# Why Calculations are Useful for Your Tableau Visualizations

Calculations can be a useful tool for your Tableau visualizations. If you have experience using databases, you’re probably aware that in most cases, those databases are designed to hold only as much information as is needed. Often, information that can be derived from the database using calculations isn’t stored.

An example that’s commonly cited is the line total of a sale. Often the sales price and quantity sold are stored, but the total is not because it can be calculated by multiplying the first two.

Take a look at some of the ways that you can use calculations in Tableau.

## Calculated fields

Calculated fields are fields that you create that don’t already exist in your data source. These calculated fields are created using formulas that are often based on other fields.

For example, this shows a calculated field called Profit Ratio, which uses the formula SUM([Profit]) / SUM([Sales]). After you’ve created this calculated field, you can use it in your views or in other calculations just like any existing field in the data source.

Notice that field names used in formulas are enclosed in square brackets. Technically, Tableau only requires the brackets for field names that contain spaces, but it’s a good practice in any event because if you forget to include them when they are needed, you’ll have an error that’s hard to find.

## Table calculations

Table calculations are applied to values that come back from the database at some aggregation level. It’s akin to building a pivot table and running calculations on it afterwards. Table calculations rely on the detail (and often the structure) of the view.

You can use Tableau’s Table Calculation options to show things such as running totals, rankings, or even growth. Table calculations frequently calculate values across two or more rows. For example, a table calculation could figure out how much this month’s sales compare to last month’s sales in cases where your result set returns a row for each month.

Tableau marks table calculations by placing a triangle mark at the right side of the field, indicating that a change has been made.