What is Crosstab in Tableau?
Crosstab in Tableau, also known as text tables or pivot tables, is a data visualization feature that allows you to present your data in a tabular format. A crosstab includes one or more dimensions in the Rows shelf and one or more dimensions in the Columns shelf. It also uses a Text mark type for data visualization. Crosstab can be a helpful visualization tool where you can display a list of details or basic numbers, such as sales numbers across different categories, upcoming timelines, marks across different subjects, etc., in a tabular format.
Crosstab in Tableau has many advantages which include the following:
- Displaying a chart where specific numbers are not required to be visualized
- Using a crosstab can help users identify specific values
- You can display KPIs in a large format to put the spotlight on critical values
- Crosstabs can help you display the data in percentages
A sample crosstab is provided below.

Key Takeaways
- Crosstab in Tableau allows you to present your data in a tabular format.
- Crosstab includes one or more dimensions in the Rows shelf and one or more dimensions in the Columns shelf.
- Crosstab can be a useful visualization tool for displaying a list of details or basic numbers such as sales numbers across different categories, upcoming timelines, marks across different subjects, etc. in a tabular format.
- You can add filters to a crosstab, export crosstab in Tableau, and sort the values. Additionally, you can also include totals and subtotals in a crosstab.
How to create a crosstab in Tableau?
To create a crosstab in Tableau, follow the instructions below:
Step 1: Import your data source into Tableau Public.

Step 2: Click on a new worksheet. Drag the dimensions to the Rows and Columns shelves, respectively. Drag the measure to the Text on the Marks card.
Tableau will create a text table or crosstab as shown below. You can see the row headers comprising the dimensions in the Rows shelf. The column headers include the dimensions in the column shelf.
The combination of Row and Column headers is displayed in the form of a crosstab. The values displayed in each cell are the measure values mapped to Text on the Marks card. Each cell value is the aggregated value of the specified measure in the Text mark type.

Note: You can create dynamic crosstab in Tableau using parameters. Similarly, you can duplicate as crosstab in Tableau by right-clicking on a worksheet and choosing the Duplicate option.
Examples
In this section, we have demonstrated different use cases for creating crosstabs in Tableau.
Example #1 – Crosstab with Row Percentage
In this example, we will create a crosstab with row percentages in Tableau using the Trends in Consumer dataset, which is a comprehensive collection of complaints related to consumer financial products and services, initially submitted by consumers and then forwarded to the respective companies for a formal response.
To create a crosstab with row percentage in Tableau, follow the instructions outlined below:
Step 1: Connect to the Trends in Consumer dataset from the Tableau interface.

Step 2: Create a data visualization by dragging Submitted via to the Columns shelf and Product and Sub-Product to the Rows shelf. Drag the Complain ID to the Text on the Marks card. Tableau will create a Text Table in the view, as shown below.

Step 3: Right-click on the Complaint Id field on the Text on the Marks card and select Measure – Count.

Tableau will change the measure to display the total count of complaints in the view.

Step 4: Right-click on the CNT(Complaint ID) on the Text part on the Marks type and select the Add Table Calculation option from the context menu.

Step 5: A Table Calculation screen opens. Here, choose Calculation Type as Percent of Total from the drop-down.

Step 6: In the Table Calculation screen, choose the Compute Using as Table option.

Now, you will see the measure values displayed as percentages for each combination of Product and Sub-product in the Tableau view. Each percentage represents the ratio of complaints in comparison to the total complaints across all products and sub-product combinations.

Step 7: To create a row percentage in each row, right-click on the CNT(Complaint ID) and select Edit Table Calculation from the context menu.

Step 8: In the Table Calculation screen, choose Compute Using as Table(across).

As you can see, Tableau has now changed the percentage values to display crosstab with row percentages, as shown below.

Example #2 – Color Encoded Crosstab
In this example, we have demonstrated how you can create a color-encoded crosstab in Tableau using the Brands’ Sales and Ad Spend data.
To create a color-encoded crosstab in Tableau, follow the instructions outlined below:
Step 1: Import the Brands’ Sales and Ad Spend dataset into the Tableau interface using File – Open functionality.

Step 2: Navigate to a new worksheet. Drag Brand Name to the Columns shelf and Country to the Rows shelf from the Data pane to the Tableau view.
Tableau will create a text table or crosstab, as shown below.

Step 3: Drag the Total Ad Spend measure to the Text mark type on the Marks card. Tableau will populate the text table with values in the view for each applicable cell as per the combination of the Brand Name and Country.

Step 4: Drag the Total Ad Spend to the Color on the Marks card. Tableau will add color encoding to the view as per the values. You can see the color range in the right corner of the view.

Step 5: Click on Color – Edit Colors. In the Edit Colors screen, click on the Palette drop-down and select the Red-Green Diverging option.

Step 6: Click on OK to save the changes. It will apply formatting crosstab in Tableau.

Now, you can see the color-encoded crosstab according to your color palette selection in the Tableau view, as shown below.

Example #3 – Custom table headers for crosstab
In this example, we will demonstrate how to create custom table headers for crosstab in Tableau. Note that Tableau doesn’t provide a built-in feature for this. For this demonstration, we have used the Forbes Top 500 Companies dataset, which contains insight into the world’s largest companies, including the metrics used to compile the list—sales, profits, assets, and market value.
To create custom table headers for crosstab in Tableau, follow the instructions outlined below:
Step 1: Import the Forbes Top 500 Companies data into Tableau public.

Step 2: Go to a new worksheet. Click on Analysis – Create Calculated Field.

Step 3: In the Calculation Editor screen, create a field named 0 with logic, as shown below. Click on OK.

Step 4: Right-click on the Data pane and choose Create Calculated Field.

Step 5: In the Calculation Editor, specify the name of the field and logic to populate the value, as shown below.
Here, we have created a field called placeholder.

Step 6: Drag the Country and Company Name fields to the Rows shelf and Measures Names to the Columns shelf.
Drag Measure Values to the Text on the Marks card.
Drag Measure Names to the Filters pane.

Step 7: In the Filter [Measure Names] screen, select the required fields and click on OK.

Step 8: Drag the Company Name to the Filters pane. In the Filter screen, navigate to the Top tab.
Specify the filter logic to display the top 20 countries by total assets in Billion.

Now, your Tableau visualization looks like the one provided below.

Step 9: In a new worksheet, drag the field created in Step 3 to the Columns shelf. Repeat it six times to create a visualization like the one provided below.

Step 10: Click on All Marks card and change the marks type to Text.

Tableau will change the view, as shown below.

Step 11: Drag the field placeholder created in Step 5. Move it to the Text on the All Marks card.

Step 12: Expand AGG(0) Marks card. Then, double-click on the Text and change the value to “Country”.

Step 13: Click on Text and then click on ellipsis (…) next to the Text. In the Edit Label window, select the text i.e. <” Country”>, and change the font to Arial, Bold, and other formatting options.

Step 14: Right-click on the view and uncheck Show Header, as shown below.

Tableau will update the view with the Country header as shown below.

Step 15: Expand AGG(0)(2) Marks card. Repeat steps 12 and 13 to create a header Company Name, as shown below.

Tableau will update the view by displaying two headers, as shown below.

Step 16: Expand the AGG(0)(3) Marks card and change the mark type to Square. Adjust the size to fill the entire cell.

Step 17: Let us do the next step. Add the column name to the header.

Step 18: Adjust the alignment as per below.

Step 19: Repeat the steps to add column names for Market Value (in Bn), Profit(in Bn), and Sales(in Bn).



Now, your custom table headers are ready.

Step 20: Add color coding to the columns. Do it as shown below.


Step 21: Navigate to the previous worksheet and hide the field labels for rows.

Step 22: Similarly, click on the down arrow next to the Measure Names and uncheck Show Header.

Now, your Tableau worksheet is updated with the below view.

Step 23: Create a new dashboard and drag the Custom Header worksheet to the view. Select Floating to adjust the view.

Step 24: Drag the visualization sheet to the dashboard view.

Step 25: Hide the titles from both the visuals and adjust the visualizations.

Now, your custom table headers for crosstab are ready for visualization, as shown below.

Important Things to Note
- The order of columns in a crosstab is analyzed from left to right, not the reverse order, which is not supported.
- The dimensions must be on the left side, whereas the measures should be on the right side of the dimensions.
- By default, crosstab follows the sorting of columns in left-to-right order.
- Similarly, crosstab groups the values that are repeated in a column for consecutive rows in the left-to-right order
- Crosstabs are not an ideal choice for
- narrating any captivating storyline
- displaying considerable data in a constrained visual
- visualizing key relationships between multiple categories
- displaying demographics visuals
- Crosstabs contain lots of data in a tabular format that may be cumbersome to consume.
Frequently Asked Questions (FAQs)
There are two ways you can add filters to a crosstab in Tableau. They include Quick Filters and Context Filters. While Quick Filters allow you to apply filter conditions to a field, Context Filters allow you to apply filter conditions by dragging the fields to the Filters pane.
Yes, you can export crosstab in Tableau. To export,
• Navigate to Worksheet – Export.
• Now, choose the format in which you want to export crosstab in Tableau, i.e., PDF, Image, CSV, etc.
To sort data within a crosstab in Tableau, choose the header or the column you want to sort. Then, select the sort icon ascending or descending to apply sorting.
Yes, you can include totals and subtotals in a crosstab in Tableau. You can do so by following the steps below:
Navigate to the Analytics pane
For Totals, Under Summarize, drag the Totals into the Add Totals dialog, and drop it over either the Row Grand Totals or Column Grand Totals option.
For Subtotals, Under Summarize, drag the Totals into the Add Totals dialog, and drop it over Subtotals
Recommended Articles
Guide to What Is Crosstab in Tableau. We learn how to create a crosstab in Tableau, with examples and points to note. You can learn more from the following articles –
Leave a Reply