Not everyone is a Tableau guru, at least not yet. To help Tableau rookies, we’re starting from square one with the Tableau Essentials blog series. The series is intended to be an easy-to-read reference on the basics of using Tableau Software, particularly Tableau Desktop. Since there are so many cool features to cover in Tableau, the series will include several different posts.
Not everyone is a Tableau guru, at least not yet. To help Tableau rookies, we’re starting from square one with the Tableau Essentials blog series. The series is intended to be an easy-to-read reference on the basics of using Tableau Software, particularly Tableau Desktop 8.1 and 8.2. Since there are so many cool features to cover in Tableau, the series will include several different posts. This is the tenth post in the series. Check out the full list on our Tableau Essentials blog channel. This is also the first post in the Calculated Fields sub-series.
Today, we’ll scratch the surface on calculated fields in Tableau. There’s obviously a lot to cover in this particular section, and we’ll dig deeper into the various functions, formulas and capabilities with future articles, but today we’ll start simple and easy.
First, to open the Calculated Box dialogue window, you can right-click anywhere in the Data Window (also known as the Sidebar) to bring up the following contextual menu (OR under the Analysis menu at the top toolbar OR on the drop-down arrow next to the at the top right corner of the Dimensions box OR right-click on any field — many ways to achieve the same thing in Tableau):
Select Create Calculated Field. Alternately, if you have an existing calculated field, you can right-click on that particular field and click Edit. However, when you get to the Calculated Box window, you’ll be presented with several different options:
The Name at the top of the box will be how the name of your new field will appear in the Data Window. Make the name something descriptive that will aid you in identifying it when it’s not so fresh in your mind. There are some great tips for controlling your metadata in Tableau here. The text box beneath is where you’ll build your calculation. Tableau offers several tools to help:
- Fields: Here’s an alphabetical list of all the fields (both dimensions and measures) in your worksheet’s data source. You can use the drop-down menu at the top to help you filter the different fields you have by data type. Clicking once on any of the fields will bring up more information in the far-right text box (light yellow shading with rounded corners). Double-clicking on a field will insert it into your calculation work area running across the top of the screen. Fields are case-sensitive and require brackets [ ] around them when used in a formula.
- Parameter: If you have any parameters that you have created, then you can also use them in your calculation. You do have the option to click on the Create button and make a new parameter on the fly. Parameters need brackets [ ] around them while used in a formula and, like fields, they are case-sensitive.
- Functions: The drop-down list of functions shows you what’s possible to use in Tableau. When you select a function, the yellow-shaded text box next to the functions list is like a cheat sheet for different formulas to use in your calculated field. There are far too many for us to detail in this article, so we’ll address functions in future blogs. The drop-down menu will filter the different types of formulas based on type:
We’re going to focus on a simple calculation just to illustrate how the formula area works. Let’s create a simple subtraction formula by clicking on one measure, entering a subtraction sign and then clicking on another measure:
Tableau will automatically check to see if your calculation is valid. You can see Tableau’s green check mark at the bottom of the formula text area. Let’s purposefully enter a broken formula to see what happens. We’ll take the above formula and divide it by a text field:
The red x indicates that we’ve got a problem with our formula. Tableau goes another step and offers a drop-down area at the end of the error message to help us troubleshoot our mistake:
Tableau picked up right away on our text field error. If you click on the error message, Tableau will take your cursor to the problem area of your formula for you to fix. When we’ve corrected the error, we’ll click OK and complete our calculation.
The new calculation will appear in the data window with a special icon to indicate that it is a calculation: “=”
With all of the different formulas available in the Calculated Field window, it’s clear that there’s an incredible amount of power that Tableau offers in building custom formulas, calculations and advanced fields. The best way to develop mastery in Tableau once you’ve established the basics is to test and explore. And remember, if you make any mistakes, just use that handy Undo button in the toolbar.
Calculated Fields
Calculated fields can add a whole new layer of insight to your Tableau dashboards. The possibilities are practically endless, but we’ll be covering the fundamentals, especially functions, to help you build a foundational understanding of how and when to use them. Check back for more posts covering:
- Logical Functions
- Number Functions
- Date Functions
- String Functions
- Type Conversion
- Aggregate Functions
- User Functions
Another great resource for functions is Dan Murray’s best-selling guidebook, “Tableau Your Data!” It features a whole section devoted the functions we’ll be covering in this series and much, much more.
More Tableau Essentials
Want to learn more about Tableau? Here are the other Tableau Essentials posts we have so far:
- The Toolbar (Interface)
- The Sidebar (Interface)
- The Worksheet Canvas (Interface)
- Measures & Default Properties
- Connect to Data
- Title, Caption & Summary
- The Status Bar
- Chart Types (Sub-series)
- Formatting Tips (Sub-series)
- Calculated Fields (Sub-series)
More articles are coming soon, so check back regularly.
As always, let us know if you have any questions or comments about this post or Tableau in general. If you’re looking for personalized training or help with something bigger, contact us directly!