KNOWLEDGE BASE

## How to Compute a Cumulative Grand Total in a Crosstab

Published: 29 May 2023

### Question

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

Current Behavior

Desired Behavior

### Environment

• Tableau Desktop

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.

3. Drag Sales to Text on Marks.

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.

7. Right-click on Grand Total on the Crosstab and select Format.  Enter "Computing Cumulative" to the Grand Totals Label.

#### Step 3

Create the Grand Total sheet.

8. Duplicate the sheet.  Drag Sales on the Computing Cumulative Grand Total placed on Text.

#### Step 4

Create the dashboard.

9. Create a new dashboard then select Floating.

10. Drag Computing Cumulative sheet to the dashboard.  From the drop-down arrow, click on Title to hide the title.

11. Drag Grand Total sheet to the dashboard.  Adjust the Computing Cumulative to be placed below the Grand Total row.