Tableau Deep Dive: Parameters – Table Calculations

Data

Tableau Deep Dive: Parameters – Table Calculations

Tableau Deep Dives are a loose collection of mini-series designed to give you an in-depth look into various features of Tableau Software.

At the start of this Deep Dive series, I stated that there were four standard use cases for parameters: filters, bins, reference lines and calculated fields. What about other areas, such as table calculations? Why can’t we use parameters there?

The answer is: You can!

You just have to do a little extra work. Let’s start by looking a standard table calculation and then how we would add a parameter to it.

Table Calculations in Tableau

To add a table calculation, I right-click on any measure used in my view and select Add Table Calculation or Quick Table Calculation. I’m going to start with the initial view of Profit displayed over continuous months:

Initial Tableau view

I want to add a table calculation to my Profit measure for a moving average:

Add table calculation in Tableau

Here’s the Table Calculation window that pops up:

Tableau Table Calculation window

Perhaps I want to add a parameter for my Previous Values. I want to be able to give my user the option of changing how many previous values are used to calculate the moving average. This allows the user to decide how little or how much emphasis is placed on recent values. The more values we include, the smoother our moving average is going to look.

Unfortunately, Tableau doesn’t offer me the option to include a parameter inside of my Table Calculation window. There’s nothing in this window that allows me to select a parameter. At first glance, I may just assume that a parameter can’t be used with this use case.

But wait … we can …

Turning a Table Calculation into a Calculated Field

We can take any table calculation that we’re using in our view and drag it to the data pane to save it as a calculated field. That’s the secret of using a parameter inside of a table calculation. Let’s drag the same moving average table calculation to the Data pane and see how it looks inside of the calculated field editor:

Profit Moving Average calculation in Tableau

Window_Avg is the function that is performing our moving average within our table calculation. In this form as a calculated field, we can add our parameter. Let’s change the Previous Values to a parameter to allow the user to include the last two months, six months and 12 months.

Let’s build the parameter. In constructing our list of values, remember that we need to use negative numbers to represent previous values. In the Window_Avg function, the previous two values is represented as a -2, so we’ll frame our list of values as -2, -6 and -12.

Tableau > Create Parameter > Moving Average Option

Now, let’s use our parameter in our calculation:

Using parameter in calculation

Finally, we need to show our parameter control. Our view now has a parameterized table calculation as such:

Our Tableau view with a parmeterized table calc

Boom goes the dynamite. Just for fun, let’s go back to our Table Calculation window to see how Tableau has adjusted the settings given that we just added a parameter:

Tableau adjusting settings

The window options have been changed to reflect the changes that we made in the Calculated Field editor. The summary of our new calculation is listed under the Formula area.

What’s Next?

Obviously, there are a lot of different table calculations that you can use with parameters. That concludes our deep dive on parameters in Tableau. Don’t be sad, we’ll be back very soon with another series of articles. Have a request? Questions? Thoughts? Leave all of it in the comments section below.

Want More Tableau Deep Dives

  1. Tableau Deep Dive: LOD – Introduction to Detail
  2. Tableau Deep Dive: LOD – The Include Calculation
  3. Tableau Deep Dive: LOD – The Exclude Calculation
  4. Tableau Deep Dive: LOD – The Fixed Calculation
  5. Tableau Deep Dive: LOD – LOD Calculations vs. Table Calculations
  6. Tableau Deep Dive: Parameters – Parameter Overview
  7. Tableau Deep Dive: Parameters – Parameter Properties
  8. Tableau Deep Dive: Parameters – Filtering – Top N
  9. Tableau Deep Dive: Parameters – Calculated Fields
  10. Tableau Deep Dive: Parameters – Filtering Across Data Sources
  11. Tableau Deep Dive: Parameters – Bins
  12. Tableau Deep Dive: Parameters – Reference Lines
  13. Tableau Deep Dive: Parameters – Table Calculations
  14. Tableau Deep Dive: Sets – Introduction to Sets
  15. Tableau Deep Dive: Sets – Constant Sets
  16. Tableau Deep Dive: Sets – Computed Sets
  17. Tableau Deep Dive: Sets – IN/OUT
  18. Tableau Deep Dive: Sets – Combined Sets
  19. Tableau Deep Dive: Sets – Calculated Fields
  20. Tableau Deep Dive: Sets – Hierarchies
  21. Tableau Deep Dive: Dates – Introduction to Dates
  22. Tableau Deep Dive: Dates – Preparing Dates
  23. Tableau Deep Dive: Dates – More Date Functions
  24. Tableau Deep Dive: Dates – Exact Dates
  25. Tableau Deep Dive: Dates – Custom Dates
  26. Tableau Deep Dive: Dates – Rolling Dates
  27. Tableau Deep Dive: Dates – Calendar Filters
  28. Tableau Deep Dive: Dates – Week-by-Week Comparison
  29. Tableau Deep Dive: Dashboard Design – Planning
  30. Tableau Deep Dive: Dashboard Design – Layout & Structure
  31. Tableau Deep Dive: Dashboard Design – Proof of Concept
  32. Tableau Deep Dive: Dashboard Design – Adding Interactivity
  33. Tableau Deep Dive: Dashboard Design – Visual Best Practices
  34. Tableau Deep Dive: Dashboard Design – Optimization & Governance
  35. Tableau Deep Dive: Dashboard Design – Publishing
  36. Tableau Deep Dive: Table Calculations – Custom Sorts, Part One
  37. Tableau Deep Dive: Table Calculations – Custom Sorts, Part Two
  38. Tableau Deep Dive: Table Calculations – Custom Sorts, Part Three

More About the Author

Robert Curtis

Managing Director, APAC
Kickstarting Data Innovation in Healthcare On 13 March 2024, InterWorks was a proud Platinum sponsor of the first ever Data & Analytics in Healthcare conference, hosted by ...
Building Solutions with InterWorks at Corinium’s Data Architecture Conference in Melbourne InterWorks was a proud sponsor of the Data Architecture Conference hosted by Corinium in Melbourne on 21 and 22 June 2023. Hundreds of ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×

Love our blog? You should see our emails. Sign up for our newsletter!