1. Introduction to calculations
Welcome to this course!
Using calculations is indispensable in any data work and combining this skill with data visualization can truly bring your analysis to the next level.
I am Agata Bak-Geerinck and together we will study calculations in Tableau from the foundations to more advanced concepts. Let's get started.
2. Why do calculations?
Calculations allow you to create new data from already existing data and perform computations on your data.
Let's consider some typical use cases.
Sometimes a crucial measure is missing in the original dataset; for example, you’ve got Sales and Costs but no Profits. With Sales and Costs, you can calculate Profit yourself!
Or, you might want to transform existing data, such as extracting the First name from a field containing both First and Last names.
Another example is categorizing your data by grouping Ages into kids, teens, and adults.
These only are a few applications.
3. Types of calculations in Tableau
There are 4 main types of calculations in Tableau.
We will cover two of the most basic and common calculations, row-level and aggregation calculations, in this chapter, and we will focus on more advanced ones, the Level of Detail and Table Calculations, in the following chapters.
4. Row-level calculations vs. aggregations
Let's have a look at these most common calculation types.
The most basic is Row-Level calculation. It is performed on every row of the data, similar to basic computations in spreadsheet rows.
For example, calculating the difference between the start and end date will give us a value for every record.
Next up are the aggregations, such as SUM, AVERAGE, COUNT, MAXIMUM, MINIMUM, and others. You know them, for example, from Excel's pivot tables.
These calculations are performed on a set of underlying records, the rows of data, and are strictly defined by the dimensions in the view. For example, to calculate the SUM of Profit, we sum the Sales and subtract the sum of costs, and the result would be a single value.
If we, however added a dimension to the view, for example, a region, the SUM of Profit would be recalculated per region.
Understanding these two types of calculations will save you a lot of time and trouble when working in Tableau.
5. Most common calculation errors
Errors in calculations happen!
The good news is that Tableau has a built-in validity check and will help us troubleshoot some of the calculation errors but nailing the right syntax can be tricky, so here is an overview of some typical errors.
Mixing up the row-level and aggregate calculations will result in this error. To fix this, work only with either row or only aggregated calculations in one formula.
Another common mistake is performing calculations on a field with an incompatible data type, e.g., summing the dates.
Yet another trivial but common error is missing a syntax element, an identifier or operator, comma, or parenthesis, or using an incorrect type of brackets.
We will see these errors again in the exercises.
6. Most common logical errors
However, be aware that calculation validity check is only performed on the syntax of your formula and not on logical or mathematical correctness.
Here are some typical logical errors which will render a valid calculation in Tableau:
Applying mathematical operations in the wrong order, incorrect use of brackets in AND and OR statements, wrong application of conditions in IF and Case functions, summing instead of counting, averaging an average, and many others.
Remember that the final analytical responsibility lies with you, so always double-check your calculations!
7. The dataset - Fitbit usage
Lastly, let’s have a look at the dataset which we will use in this chapter. We will be working with Fitbit data and analyze users Sleep, Heart Rate, Steps and other Activities' statistics.
8. Let's practice!
Let's practice!