Welcome to Module 5! In the previous module, you learned how to create charts such as bar charts, line charts, pie charts and scatter plots in Tableau.
In this module, you will learn how to use calculations to understand your data better.
Imagine that you own a small supermarket in Ibadan. You sell rice, bread, milk and other products. At the end of the week, you want to know:
Instead of calculating everything with a calculator, Tableau can help you analyse the information.
A calculation is a mathematical operation that helps you get useful information from your data.
For example, imagine you have these sales records:
| Product | Quantity Sold | Price per Item |
|---|---|---|
| Rice | 10 | ₦5,000 |
| Bread | 20 | ₦1,000 |
| Milk | 15 | ₦2,000 |
To calculate the total sales for each product, multiply the quantity sold by the price per item.
Formula:
Total Sales = Quantity Sold × Price per Item
Quantity sold = 10 bags
Price per bag = ₦5,000
Total sales = 10 × ₦5,000
Total sales = ₦50,000
Tableau allows you to create calculations like this using calculated fields.
A calculated field is a new field you create in Tableau using a formula.
For example, your dataset may contain Quantity and Price, but it does not contain Total Sales.
You can create a calculated field called Total Sales and ask Tableau to calculate it automatically.
Use this formula:
[Quantity] * [Price]
Tableau will create a new field that calculates the sales value for each row.
Tableau provides functions that help you calculate and understand information quickly.
The SUM function adds numbers together.
Example:
SUM([Sales])
This adds all the values in the Sales field.
If your sales records are ₦10,000, ₦20,000 and ₦30,000, the result is ₦60,000.
The AVG function calculates the average of a group of numbers.
Example:
AVG([Score])
If three students score 60, 70 and 80, their average score is:
(60 + 70 + 80) ÷ 3 = 70
The COUNT function counts the number of non-empty values in a field.
Example:
COUNT([Student Name])
If your dataset contains 50 student names, COUNT can return 50.
The MIN function finds the smallest value.
Example:
MIN([Sales])
If your sales values are ₦5,000, ₦10,000 and ₦15,000, the smallest value is ₦5,000.
The MAX function finds the largest value.
Example:
MAX([Sales])
If your sales values are ₦5,000, ₦10,000 and ₦15,000, the largest value is ₦15,000.
| Function | What It Does |
|---|---|
| SUM() | Adds values together |
| AVG() | Finds the average |
| COUNT() | Counts non-empty values |
| MIN() | Finds the smallest value |
| MAX() | Finds the largest value |
Aggregation means combining many values into one result.
For example, imagine a supermarket sells rice on five different days:
| Day | Rice Sales |
|---|---|
| Monday | ₦20,000 |
| Tuesday | ₦15,000 |
| Wednesday | ₦25,000 |
| Thursday | ₦10,000 |
| Friday | ₦30,000 |
When Tableau uses SUM(Sales), it combines the sales values to show the total.
Total sales = ₦100,000.
When Tableau uses AVG(Sales), it calculates the average daily sales.
Average = ₦100,000 ÷ 5 = ₦20,000.
Tableau often displays measures using aggregations such as SUM or AVG. You can change the aggregation depending on the question you want to answer.
Imagine a school in Lagos wants to understand the performance of its students.
The school has collected these examination results:
| Student | Mathematics | English | Science |
|---|---|---|---|
| Ada | 80 | 75 | 90 |
| John | 65 | 70 | 75 |
| Mary | 90 | 85 | 95 |
You can create a calculated field called Total Score.
Formula:
[Mathematics] + [English] + [Science]
You can also create another calculated field called Average Score.
Formula:
([Mathematics] + [English] + [Science]) / 3
Tableau can calculate these values for every student in the dataset.
Sometimes, you want Tableau to make a decision based on a condition.
For example, a school may want to classify students who score 50 or above as Pass and those who score below 50 as Needs Improvement.
You can use an IF statement.
Example formula:
IF [Score] >= 50 THEN "Pass" ELSE "Needs Improvement" END
This means:
| Student | Score | Result |
|---|---|---|
| Ada | 80 | Pass |
| John | 45 | Needs Improvement |
| Mary | 90 | Pass |
After creating a calculated field, you can use it in your charts just like other fields.
For example, if you create a Total Sales field, you can:
You can also drag Average Score into a chart to compare student performance.
This makes it easier to understand your information without reading hundreds of numbers.
Now it is your turn to become a data analyst!
Imagine you work for a supermarket in Ibadan. The manager gives you the following information:
| Product | Quantity Sold | Price per Item |
|---|---|---|
| Rice | 10 | ₦5,000 |
| Bread | 20 | ₦1,000 |
| Milk | 15 | ₦2,000 |
| Noodles | 30 | ₦500 |
| Soft Drinks | 25 | ₦800 |
[Quantity Sold] * [Price per Item].Which product made the most money for the supermarket?
Can you explain how your Tableau chart helped you find the answer?
Answer these questions to test what you have learned.
What is a calculated field in Tableau?
Which Tableau function adds values together?
Which function calculates the average?
What does MAX() do?
Which function finds the smallest value?
What is the result of adding 10, 20 and 30 using SUM?
Which formula calculates total sales?
What is the purpose of an IF statement?
What does COUNT() count?
What can you do with a calculated field after creating it?
Well done! You have completed Module 5.
In this module, you learned how to:
Remember, Tableau is not just for drawing charts. It also helps you calculate, compare and understand information.
In the next module, you will learn how to combine different charts into one interactive dashboard. You will also learn how to use dashboard filters and actions to explore information easily.
Keep practising. You are becoming a data analyst!