Reader small image

You're reading from  The Tableau Workshop

Product typeBook
Published inApr 2022
Reading LevelBeginner
PublisherPackt
ISBN-139781800207653
Edition1st Edition
Languages
Tools
Right arrow
Authors (5):
Sumit Gupta
Sumit Gupta
author image
Sumit Gupta

Sumit Gupta is an analytics professional with more than 7 years' experience spanning across marketing, sales, and product analytics. As a consultant and trainer, he has utilized Tableau to build better data-driven teams for his organization. Sumit specializes in translating vast amounts of data into easy-to-understand dashboards which provide actionable intelligence. He is a Tableau Certified Associate and enjoys training data enthusiasts to become better Tableau developers and certified Tableau associates. This book is one such effort to reach masses.
Read more about Sumit Gupta

Sylvester Pinto
Sylvester Pinto
author image
Sylvester Pinto

Sylvester Pinto has been using Tableau for almost a decade now for improving business performance for different industries. Sylvester has designed various business solutions using Tableau for different organizations leading to a huge impact to improve their businesses. He has a Tableau certification and as a consultant designs solutions for various organizations.
Read more about Sylvester Pinto

Shweta Sankhe-Savale
Shweta Sankhe-Savale
author image
Shweta Sankhe-Savale

Shweta Sankhe-Savale is the Co-founder and Head of Client Engagements at Syvylyze Analytics (pronounced as "civilize"), a boutique business analytics firm specializing in visual analytics. Shweta is a Tableau Desktop Qualified Associate and a Tableau Accredited Trainer. Being one of the leading experts on Tableau in India, Shweta has translated her experience and expertise into successfully rendering analytics and data visualization services for numerous clients across a wide range of industry verticals. She has taken up numerous training as well as consulting assignments for customers across various sectors like BFSI, FMCG, Retail, E-commerce, Consulting & Professional Services, Manufacturing, Healthcare & Pharma, ITeS etc. She even had the privilege of working with some of the renowned Government and UN agencies as well. Combining her ability to breakdown complex concepts, with her expertise on Tableau's visual analytics platforms, Shweta has successfully trained over a 1300+ participants from 85+ companies.
Read more about Shweta Sankhe-Savale

JC Gillet
JC Gillet
author image
JC Gillet

Jean-Charles (JC) Gillet is a seasoned business analyst with over 7 years of experience with SQL at both a large-scale multinational company in the United Kingdom and a smaller firm in the United States, and 5 years of Tableau experience. He has been working with Tableau and SQL for multiple years to share his expertise with his colleagues, as well as delivering SQL training. A French national, JC holds a master's degree in executive engineering from Mines ParisTech and is a Tableau Desktop Certified Associate. In his free time, he enjoys spending time with his wife and daughter (to whom he dedicates his work on this book) and playing team handball, having competed in national championships.
Read more about JC Gillet

Kenneth Michael Cherven
Kenneth Michael Cherven
author image
Kenneth Michael Cherven

Kenneth Michael Cherven is a Data Analyst and Visualizer based in Detroit, Michigan, USA. He has worked with Tableau for more than 15 years with a focus on making complex data easily understood through the of interactive dashboards and creative displays. Beyond his work in the automotive sector, Kenneth analyzes data and creates visualizations using open data sources from the baseball, government, music, and craft beer domains. Ken has previously published two titles for Packt – Network Graph Analysis and Visualization with Gephi and Mastering Gephi Network Visualization.
Read more about Kenneth Michael Cherven

View More author details
Right arrow

7. Data Analysis: Creating and Using Calculations

Overview

In this chapter, you will learn to create and use various types of calculations, not just within an existing data source, but also across data sources. This chapter first describes the definitions and the differences between Aggregate and Non-Aggregate values. Then, you will learn about various types of calculations, such as numeric calculations, string calculations, and date calculations, as well as how to write logic statements in Tableau.

By the end of this chapter, you will be able to create and use various types of calculations in Tableau.

Introduction

Typically, the first step when analyzing data is to start with some questions or goals. It could be as simple as determining your most profitable customers, or more complicated, such as investigating which products are leading to losses despite high sales. After deciding on questions or goals, you would audit your data. This means identifying where data resides—whether the required fields are stored in a single or in multiple data sources and whether all fields are readily available for use. Then, you would check the integrity and validity of your data. This means checking whether the data needs any modifications in terms of cleaning, combining, or restructuring.

Once data is audited, the tools in Tableau Desktop allow you to explore it visually for more streamlined analysis. This can mean building charts, adding interactivity, separating data into groups, or creating calculations to derive more meaningful insights. Once analysis is complete, the insights you...

Creating and Using Ad hoc / Edit in Shelf Calculations

Ad hoc / Edit in Shelf calculations are the quickest and easiest way to create a new calculated field in Tableau. Ad hoc calculations can be created in the Rows, Columns, and Measure Values shelves, as well as in the Marks cards.

Simply double-click on the existing field in your shelf of choice, or, alternatively you can use the Edit in Shelf option in the drop-down list of that field, as shown in the following figure:

Figure 7.10: A screenshot showing how to create an ad hoc calculation

These ad hoc calculations are useful when creating quick, on-the-fly calculations that you may or may not want to save and reuse. You will explore this in the exercise below.

Exercise 7.01: Creating an Ad Hoc Calculation to Highlight Loss-Making Sub-Categories

The aim of this exercise is to find out which sub-categories have negative profit and which ones have positive profit. Those with negative profit will...

Creating and Using Different Types of Calculations

Tableau is a simple yet versatile tool, and the ability to create calculations gives users the flexibility to perform powerful analysis, which can help with decision-making. Most of the time, creating calculations in Tableau is a fun experience, but sometimes it can be a little frustrating as well, especially if you are coming from a different platform to Tableau and are trying to replicate some functionality. The way these tools are structured and designed is different and trying to replicate the functionality from one tool in another can make the experience frustrating. The best way to avoid frustration while creating calculations in Tableau is to start small and get acquainted with the functions that Tableau has to offer. While writing a calculation in Tableau is easy, it is recommended that, if possible, you should try to use the built-in native features first, instead of creating a new calculated field. Some examples of these...

Handling Null Values while Creating and Using Calculations

Often, you might deal with data containing null values. These could be genuine entries in the data. For example, there may not be any Sales value to report against a particular product—even though it is part of the inventory, it may not have been sold yet. These nulls could also be because of some data entry errors. Most likely, you would identify and take care of these nulls at the data preparation stage. However, that may not always be the case. At times, you may need to tackle them within Tableau Desktop using calculations. Null values tend to pose a problem when used in calculated fields, simply because when doing arithmetic operations on fields, it may result in the output being null in Tableau. Refer to the following screenshot:

Figure 7.51 – A screenshot showing the Excel data and the output of the calculation on fields with null values

The preceding screenshot is a quick mockup...

Creating Calculations across Data Sources

In earlier sections of this chapter, you have seen how to create and use calculations, but all these calculations were done within the same data source. Having all your data in one source would be an idealistic scenario; however, that may not always be the case, and you may have to deal with data coming from multiple sources. This means you may have to compute calculations across data sources, too.

In this section, you will focus on how to create calculations across data sources using data blending. You will also look at how to create and use calculated fields to join data. You have already seen the data blending and join functionality in previous chapters, and you will use that knowledge to create and use calculations across data sources.

You will use the Modified CoffeeChain data along with Budget Sales for CofeeChain.xlsx. These can be downloaded at the following links:

Summary

In this chapter, you explored some important aspects involved in creating and using calculations in Tableau and studied the difference between aggregate and non-aggregate fields. You looked at numeric, string, and date calculations, and learned to write logic statements and handle null values. Finally, you looked at how to use these calculations across data sources.

In upcoming chapters, you will move on to more advanced table and level of detail calculations, which will allow you to do even more with your data.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
The Tableau Workshop
Published in: Apr 2022Publisher: PacktISBN-13: 9781800207653
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (5)

author image
Sumit Gupta

Sumit Gupta is an analytics professional with more than 7 years' experience spanning across marketing, sales, and product analytics. As a consultant and trainer, he has utilized Tableau to build better data-driven teams for his organization. Sumit specializes in translating vast amounts of data into easy-to-understand dashboards which provide actionable intelligence. He is a Tableau Certified Associate and enjoys training data enthusiasts to become better Tableau developers and certified Tableau associates. This book is one such effort to reach masses.
Read more about Sumit Gupta

author image
Sylvester Pinto

Sylvester Pinto has been using Tableau for almost a decade now for improving business performance for different industries. Sylvester has designed various business solutions using Tableau for different organizations leading to a huge impact to improve their businesses. He has a Tableau certification and as a consultant designs solutions for various organizations.
Read more about Sylvester Pinto

author image
Shweta Sankhe-Savale

Shweta Sankhe-Savale is the Co-founder and Head of Client Engagements at Syvylyze Analytics (pronounced as "civilize"), a boutique business analytics firm specializing in visual analytics. Shweta is a Tableau Desktop Qualified Associate and a Tableau Accredited Trainer. Being one of the leading experts on Tableau in India, Shweta has translated her experience and expertise into successfully rendering analytics and data visualization services for numerous clients across a wide range of industry verticals. She has taken up numerous training as well as consulting assignments for customers across various sectors like BFSI, FMCG, Retail, E-commerce, Consulting & Professional Services, Manufacturing, Healthcare & Pharma, ITeS etc. She even had the privilege of working with some of the renowned Government and UN agencies as well. Combining her ability to breakdown complex concepts, with her expertise on Tableau's visual analytics platforms, Shweta has successfully trained over a 1300+ participants from 85+ companies.
Read more about Shweta Sankhe-Savale

author image
JC Gillet

Jean-Charles (JC) Gillet is a seasoned business analyst with over 7 years of experience with SQL at both a large-scale multinational company in the United Kingdom and a smaller firm in the United States, and 5 years of Tableau experience. He has been working with Tableau and SQL for multiple years to share his expertise with his colleagues, as well as delivering SQL training. A French national, JC holds a master's degree in executive engineering from Mines ParisTech and is a Tableau Desktop Certified Associate. In his free time, he enjoys spending time with his wife and daughter (to whom he dedicates his work on this book) and playing team handball, having competed in national championships.
Read more about JC Gillet

author image
Kenneth Michael Cherven

Kenneth Michael Cherven is a Data Analyst and Visualizer based in Detroit, Michigan, USA. He has worked with Tableau for more than 15 years with a focus on making complex data easily understood through the of interactive dashboards and creative displays. Beyond his work in the automotive sector, Kenneth analyzes data and creates visualizations using open data sources from the baseball, government, music, and craft beer domains. Ken has previously published two titles for Packt – Network Graph Analysis and Visualization with Gephi and Mastering Gephi Network Visualization.
Read more about Kenneth Michael Cherven