Nine ways to create calculated fields

Ah the calculated fields. We all write them, we all love them. But did you know there NINE ways to write one. Let's go through them and why you should use them...

1) My Go-to

Personally I always click the carrot next to the search bar. Simple and reliable.

2) The Analysis Tab (with shortcut keys)

I have two bonus tips for this one. You can find the Create Calculated Field option in the Analysis tab.

For the Excel and keyboard shortcut lovers, you can also press Alt+A+C to select this option. You'll get the normal calculations window.

My favourite part is the 'Edit Calculated Fields' submenu. This gives you a list of all your existing calculations and lets you edit them. Very useful if you have a lot of fields and struggling to see which is the calculation you're looking for.

3) Right click a pill

You can either right click on a field or click the carrot on the right (it appears when you hover over the field). Go to create and click the 'Calculated Field' option.

The nice thing about this method is that Tableau automatically places the field in your calculation.

4) Right click an empty space on your data tab

If you right click an empty space on the data tab, you get the same menu as the first method. I like this but it becomes tricky when you have a lot of fields and not a whole lot of space.

5) Go to the data source

Go to the data source by right-clicking the tab on the bottom left. You can right click on a column header to see the option.

6) Double click the Rows / Columns card

Double clicking the Rows / Columns cards opens an ad-hoc space to write a calculation. Remember that this does not save the calculation and does not give a whole lot of space. It's great for a quick and dirty one.

Plus you can always save it by dragging the pill to the data pane!

7) The carrot on the Rows / Columns card

You can also click the carrot that appears when you hover over these cards. This opens the same area as the previous method so remember to drag the pill to the data pane if you want to save it.

8) Double click the Marks Card

The Marks card is another place that you can write ad-hoc calculations by double clicking. It behaves the same as the previous two options.

I think it's neat that you can then choose which of the Marks options the calculation applies to (e.g. color).

9) Let Tableau do it

OK. This might be cheating but Tableau will automatically create a calculation when you drag a field into any of the cards.

Right click & drag, however, and Tableau will ask what simple calculation you want! If you want to tweak it, you can always double-click the pill and edit it on ad-hoc basis.

The beauty of this method is in the automation. If you know you'll always want the same calculation done with a certain field, you can right click on it -> Default properties -> Aggregation and choose which simple calculation you want Tableau to do every time the field is dragged somewhere (see below).

So how should you create your calculated fields?

It depends. Much of it comes to personal preference. As mentioned, I almost exclusively use the first method but there are times when the others are just better.

You may not regularly use some of these methods, but it's always nice to have options.

Happy Calculating!

Author:
Ali Agah
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab