KNOWLEDGE BASE

How to Compute a Cumulative Grand Total in a Crosstab


Published: 29 May 2023
Last Modified Date: 12 Jun 2023

Question

How to add a row of values that calculates the cumulative Grand Total as shown below.

Current Behavior
User-added image
Desired Behavior
User-added image

Environment

  • Tableau Desktop

Answer

Please follow along with the attached sample workbook to the right of this text in the Attachments section.


Step 1

Create the Crosstab.

1. Connect to the Sample Superstore from Tableau Desktop.
2. Drag Region to Rows and Order Date to Columns.
User-added image
3. Drag Sales to Text on Marks.
User-added image
4. From the Toolbar, select Analysis > Totals > Show Column Grand Totals.

Step 2

Create the calculation that computes the cumulative Grand Total.

5. Create a new calculated field as follows:
     Name : Computing Cumulative Grand Total
     Calculation : IF WINDOW_MIN(MIN([Region])) = WINDOW_MAX(MAX([Region]))
                                  THEN SUM([Sales])
                           ELSE RUNNING_SUM(SUM([Sales]))
                           END
6. Drag Computing Cumulative Grand Total to above SUM(Sales) placed in Text on Marks.
User-added image
7. Right-click on Grand Total on the Crosstab and select Format.  Enter "Computing Cumulative" to the Grand Totals Label.
User-added image

Step 3

Create the Grand Total sheet.

8. Duplicate the sheet.  Drag Sales on the Computing Cumulative Grand Total placed on Text.
User-added image

Step 4

Create the dashboard.

9. Create a new dashboard then select Floating.
User-added image
10. Drag Computing Cumulative sheet to the dashboard.  From the drop-down arrow, click on Title to hide the title.
User-added image
11. Drag Grand Total sheet to the dashboard.  Adjust the Computing Cumulative to be placed below the Grand Total row.
User-added image
Did this article resolve the issue?