How to Create Custom Fields in Tableau

Join over 2 million students who advanced their careers with 365 Data Science. Learn from instructors who have worked at Meta, Spotify, Google, IKEA, Netflix, and Coca-Cola and master Python, SQL, Excel, machine learning, data analysis, AI fundamentals, and more.

Start for Free
Viktoria Hristova Viktoria Hristova 27 Apr 2023 5 min read

custom fields in tableau

There are many reasons to learn Tableau today. For one, it is the most widely used data visualization software in the business world, according to a survey conducted by Slintel. Known for its intuitive design and powerful functionalities, Tableau allows complete beginners to start creating insightful dashboards after just a couple of hours of learning. Learn the fundamentals of using it in our Introduction to Tableau course.

In this tutorial, we’ll explore easy ways to transform your source data and create custom fields in Tableau. Remember, you shouldn’t go too far with these, as Tableau’s main purpose is visualization, and not data creation or modeling.

However, sometimes it can be really handy to perform certain manipulations once you’ve loaded our data into Tableau and you need a certain type of analysis.

So, let's get started, shall we?

In This Tutorial: 

  1. Getting Started with Custom Fields in Tableau 
  2. Preparing Your Data 
  3. How to Add a Custom Field to a Tableau Table?
  4. Next Steps in Tableau

Getting Started with Custom Fields in Tableau

After loading up Tableau Public on your system, and getting the ropes of the highly intuitive interface, it’s helpful to learn some typical operators.

The typical Tableau operators you’ll need to remember are:

+ (plus) for addition

- (minus) for subtraction,

*(star) for multiplication,

/ (forward slash) for division,

And ^ (caret) for elevation;

Along with these, you’ll probably need comparison operators, such as:

= (equal),

 > (higher than),

< (lower than),

 >= (higher or equal),

 and <> (different than).

, as well as logical functions. In Tableau, they resemble the ones we have in ExcelAND, OR, and NOT

Actually, a lot of the functions and symbols used in Excel can be used when you create a calculated field.

creating a field, custom fields in tableau

So, for example, some of the most common functions are SUM (for sum), AVG (for average), MIN, and MAX (allowing you to find the minimum and maximum values within a range), and ABS (returning the absolute value of a number).

create a calculated field, custom fields in tableau

As you probably remember, we already saw the text functions LEFT and RIGHT. They allow us to extract a leftmost and a rightmost number of characters within a string we’ve specified.

Besides LEFT and RIGHT, we can also use the typical text functions available in Excel – MID (providing us with characters that are in the middle of a text string), UPPER, and LOWER (allowing us to either convert it to all uppercase characters or convert it to all lowercase characters).

lower formula, custom fields in tableau

This was a nice recap of the types of operators and functions we can use in order to create custom fields in Tableau. You can find more information on this topic here.

Preparing Your Data

Having already connected our data sourcethe Tesla Sales Data. xlxs – we are ready to go back to Tableau. But before we create some custom fields in Tableau, we will perform a few additional operations with the table we created earlier.

Right now, it shows us the number of units sold by the firm in each month of 2016 and 2017. Let’s change this measure. What we'd like it to show instead is the revenue the company generated during each of these periods.

How can we achieve that?

revenue, custom fields in tableau

Well, it’s fairly easy. Our source data contains information about price. Plus, Tableau counted the number of units sold (each row shows us a single-car sale, right?). Therefore, if we multiply the “Price” field and the auto-generated “Number of Records” field, we will obtain Revenues.

obtain revenue, custom fields in tableau

How to Add a Custom Field to a Tableau Table?

We already know how to create a calculated field. Let's name it “Revenue” and take advantage of Tableau’s auto-complete suggestions multiplying “Price” and “Number of Records”.

As we said in our previous tutorial, we can use the “star” operator to carry out multiplication. One very useful feature you have probably noticed is that at the bottom of the screen Tableau tells us whether the calculation we’ve entered is a valid one or not. Right now, our calculation is valid. If we remove a few symbols, Tableau will indicate that the calculation contains errors. This is a good guiding light when we create a calculation.

formula check, custom fields in tableau

This is our “Revenue” field. We can easily substitute the “Number of Records” data in the table with it. All we have to do is drag the “Revenue" field and position it over the “Number of Records Data”. And...Tableau replaces the two fields.

replace a field

Perfect.

Another important metric contained in our source data is ‘Gross Profit’.

By definition, ‘Revenue’ minus ‘Cogs’ equals ‘Gross Profit’.

gross profit

Currently, we have ‘Revenue’ and ‘Gross profit’. Let’s calculate ‘Cogs’ as the difference between the two.

That’s easy. All we have to do is use the minus operator.

minus operator

Nice. Let’s order our table in the following way. First, we’ll have 'Revenue', then 'Cogs', and, finally, 'Gross Profit'.

We can do that by dragging and dropping the three fields within the table. Please note that their values appear in the “Measure Values” card on the left side of the workspace area. We can change their order either from here or directly inside the table. It’s up to you.

measure values

Q&As 

How do you create a custom field in Tableau?
To create a custom field in Tableau, follow these steps:
1. Plug your data source
2. Go to “Analysis” > “Create Custom Field”
3. Enter a name for your field
4. Enter a formula for the calculation you wish to perform (these can be SUM, AVG, MIN, MAX, ABS, LEFT, RIGHT, UPPER, Lower; as well as basic symbols such as +, -, *)
5. Click “OK”
6. The custom field is added to your “Measures” list with an = sign in front of it.
7. Drag your custom field to the “Marks” card to display the results.
What is custom field in Tableau?
Custom fields are a tool for creating new data from a pre-existing data source. Creating a custom field means adding a new column of data. The difference to generated fields is that you control what goes into this field by adding certain calculations. The new field becomes a part of your Tableau dashboard, and can be expanded on with other visualization tools. Some calculations you can add to your custom fields include basic calculations denoted by mathematical symbols or formulas similar to what we have in Excel.
How many fields can you add to be shown in the label in Tableau?
Tableau has a limit of 6 fields. According to the developers themselves “we have found that using more than six separate fields can result in cluttered, hard-to-read visualizations.” Through Analysis > Table Layout > Advanced, you can increase the number of fields to 16. If you need to go even higher, there are ways you can do that too.

 Next Steps in Tableau

You have probably noticed the “Measure Names” field, which appeared in the “Columns” section. This is an auto-generated field Tableau uses in order to form our table and separate the names of different measures. If we remove it from the columns section, the table will lose its shape as all three measures will be put together.

auto-generated field

So, this is how we create custom fields in Tableau. We hope you find it useful. In our next tutorial, we’ll learn how to add totals and subtotals to our tables in Tableau.

Stay tuned!

Viktoria Hristova

Viktoria Hristova

Business Analyst

Viktoria is a business analyst with a Master’s degree in Brand Management and a Bachelor’s degree in International Relations. She is also former president and co-founder of the Global Leaders Foundation, and a popular author of various 365 Data Science publications.

Top