In contrast to Calculated Values, Quick Table calculations use the data in your Visualization to create a formula. Before you can use Quick Table calculations you must first create a worksheet that includes Visualization. Using Superstore again, below diagram displays a time series of monthly sales on top. The bottom half employs a Quick Table calculation to derive the running total of sales as the year progresses.
Time series using a running sum diagram
The steps required to build the charts in below diagram are:
The data from the sales time-series chart will serve as the data source for a quick table calculation that will be used to create the chart in the bottom half of below diagram. That chart displays the running sum of sales for each month within the displayed years. The steps required to add that portion of the view are:
The below diagram shows how right-clicking on the duplicate sales pill exposes the quick table calculation menu.
Diagram of creating the quick table calculation
Checkout Tableau Interview Questions
Selecting running total, generates the table calculation that results in the running total time series chart. The label number format was also formatted to display the results in thousands in the top chart and millions in the lower chart. The total time required to build this chart was less than 60 seconds.
Editing table calculations to suit your purpose
The table calculation editing menu diagram
You can also seen in below diagram that there are many other quick table calculation option available. There is also a menu option called edit table calculation in fact, the four rows in the menu below continuous are all used to customize table calculations.
Understanding how table calculations works take a little time for playing with the options and looking at the results. Take a close look at the edit table calculation menu option displayed in below diagram
Table Calculations require selections of the following options:
The Restarting Every option is grayed-out in below diagram because there are no discrete time or other dimension panes dividing the Time Series. Modifying the Time Series to show time as discrete quarters and months creates quarterly partitions as seen in the below diagram.
The bottom Time Series showing the Running Sum of Sales is still using Table Across to calculate the total. Right-clicking on the table calculation (denoted by a small triangle on the right side of the pill) and selecting the Edit Table Calculation Menu exposes the Running Along control. Figure below shows the Table Calculation editing menu for Running Along and includes more options. Adding the partition for quarter creates quarterly panes that can be used in the Table Calculation.
Using discrete quarter and month diagram
Changing table calculation scope diagram
Changing the scope of the calculation to pane across causes the running sum calculation to reset every quarter (pane). Figure below reflects the revised scope in the lower pane. As you see, the running totals restart at the beginning of each quarter.
Running sum set to pane across Diagram
Learning exactly how table calculations behave in different visualizations takes a little time. The best way to learn is to build a crosstab report, then start playing with different options to see the results. Tableau’s online manual provides many different examples. Figure below shows Percent of Total table calculations using all of the different standard Running Along scope options.
Checkout Tableau Server Tutorials
Notice that in this example the example for the Table scope returns exactly the same result as the Table Down Then Across scope. Also, the Cell scope is calculating the mark value of itself, resulting in 100 percent in every cell. Depending on the structure of your view it is not uncommon for different scope options to return the same values. In general, adding more dimensions to your view will increase the number of available options provided by Table Calculations. Experiment with different Visualization styles and Table Calculations. With practice you’ll be able to anticipate how they behave in different situations.
Diagram of comparison of different scope options
Quick table calculations don’t normally result in calculated values appearing on the measures shelf so what if you want to use the result returned by a quick table calculation on another worksheet? Is that possible? Table calculation functions enable you do to this.
(Related Page: What Are The Common Use Cases For Tabcmd In Tableau?)
Refer to below diagram, the quick table calculation was used generating a running sum of sales chart at the bottom. To create a calculated value using that table calculation as the source requires just a couple of steps. Right-clicking on the table calculation pill used in that chart exposes the table calculation dialog box. Below diagram shows how to convert the quick table calculation into a calculated value that is reusable in another worksheet.
Diagram of Creating a calculated value from a quick table calculation
Clicking the customize button causes the calculated value editing window to open with the formula already completed. Notice the formula employs a table calculation function running sum and the sum aggregation function together to create a new calculated value. The name field is used to type in the name that will appear on the measures shelf when the OK button is clicked. Now this table calculation can be reused in a new worksheet. Below diagram shows one possible way that it could be deployed.
In this worksheet, all four years are displayed using the customized running sum of sales measure. Notice the new measure highlighted in green on the measures shelf. The row shelf displays the new measure as a table calculation.
Diagram of using the customized table calculation in another worksheet
Secondary table calculations allow you to pass the result of an initial table calculation to a second table calculation. The next example will use some data from the United States Census. The file includes state population figures. In the next example you’ll see how a Secondary Table Calculation can be used to enhance the population analysis.
The source spreadsheet is a small list that includes the state name along with the population tally. An initial view of the data shows the population information in a bar chart, sorted by descending population. You can see the result in below diagram.
Each state is placed in order from the largest to smallest in descending order. The population values are also included as labels on each bar. There is nothing wrong with this chart. It was easy to build (requiring less than a minute). How could this be enhanced using Table Calculations? By using a Quick Table Calculation that employs a secondary pass, it will be possible to calculate running total population, and then perform a Secondary Calculation to derive the percentage of the total population represented. Below diagram was created using a two-stage table calculation using Running Sum and then deriving the percent of total in the second calculations.
United States population diagram
The dual axis chart requires the following items:
The running sum of state population and percent of total population values will be created using a calculation. Below diagram shows the table calculation edit menu with the secondary switch activated.
Diagram of dual axis chart with population and the percent of total cumulative population
Using a secondary table calculation diagram
The first running total calculation sums the state population along the scope of state. The bar chart is sorted by descending population values so the largest state is first in the table, followed by each lower ranked state in order. The secondary calculation uses the percent of total to derive the cumulative percent of total population that each state represents to the total United States population. Clicking the OK button locks in the table calculation. The result is used to create the line chart with the tables displaying the cumulative total population at that row position.
Tableau Advanced |
Tableau Server |
Data Visualization and Dashboarding Fundamentals |
Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
Name | Dates | |
---|---|---|
Tableau Training | Dec 24 to Jan 08 | View Details |
Tableau Training | Dec 28 to Jan 12 | View Details |
Tableau Training | Dec 31 to Jan 15 | View Details |
Tableau Training | Jan 04 to Jan 19 | View Details |
As a Senior Writer for Mindmajix, Saikumar has a great understanding of today’s data-driven environment, which includes key aspects such as Business Intelligence and data management. He manages the task of creating great content in the areas of Programming, Microsoft Power BI, Tableau, Oracle BI, Cognos, and Alteryx. Connect with him on LinkedIn and Twitter.