January 1, 2022

# Ultimate Guide to Tables in Tableau: Row Density

By Luke Stanke

In this post we continue our ultimate guide to tables in Tableau by discussing how to change the number of rows displayed in a table using Tableau.

As we discussed in the last post, sometimes our tables are too long in Tableau and we want to reduce the number of rows we show at a single time to our audience. We can do this with pagination (like the previous post) but we can also can do this by specifying an action on the number of rows to show! This blog post will show you how how to create this:Â

This action is great when paired with pagination (from the previous post). If you havenâ€™t caught on, I really, really, think you should combine both to make amazing tables!

This solution requires 2 sheets: one for the table and one for the control. If you are continuing from building from the previous post you can move to Step #3.

For this example youâ€™ll utilize the Sample â€“ Superstore dataset.

## Step #1: Build the base table

AddÂ [Customer Name]Â to rows. Sort this dimension descending using sum of Sales.

Next you’ll create the measures that will be on the table. You’ll then useÂ [Measure Names]Â andÂ [Measure Values]Â to build the table.

This table includes total sales, total profit, profit ratio, and total orders. Sales and profit are base measures, but you’ll need to build profit ratio and total orders. Here is profit ratio:

```				```
// Profit Ratio
SUM([Profit])/SUM([Sales])
```
```

And total orders:

```				```
// Total Orders
COUNTD([Order ID])
```
```

Now bringÂ [Measure Names]Â to columns andÂ [Measure Values]Â to text. Be sure thatÂ SUM(Sales),Â SUM(Profit),Â Profit Ratio, andÂ Total OrdersÂ are in theÂ [Measure Values]Â card.

## Step #2: Build the framework for the control

Youâ€™ll first create a parameter that will indicate how many rows to show. For this example youâ€™ll specify 15, but you can change it later.

From here click-and-dragÂ [Customer Name]Â to filters. Execute a Top N filter on sum ofÂ [Sales]Â and selectÂ [rows to show]Â to filter to the top.

## Step #3: Build the controls

Youâ€™ll create a new sheet called Controls. For this example we are going to use the power of our own data to create a placeholder that will ultimately drive the changes in the number of rows shown. Since our control has 3 options we need to pick a dimension in our data with at least 3 values. In this case we are going to useÂ [Category].

Create a calculation calledÂ [rows to show | update]. This calculation will drive your parameter updates toÂ [rows to show]Â when we build our dashboard. When Furniture is selected 10 rows will show, when Office Supplies is selected 15 rows will show and when Technology is selected 20 will show. Donâ€™t worry: you wonâ€™t see any of this on the dashboard.

```				```
// rows to show | update
CASE [Category]
WHEN "Furniture" THEN 10
WHEN "Office Supplies" THEN 15
WHEN "Technology" THEN 20
END
```
```

Create an additional calculation calledÂ [rows to show | tf]Â which will be used to highlightâ€“with colorâ€“the selected control.

```				```
// rows to show | tf
[rows to show | update] = [rows to show]
```
```

Letâ€™s build this thing! PlaceÂ [Category]Â on columns. Change the mark type to shape. PlaceÂ [Category]Â on shape. AddÂ [rows to show | tf]Â to color. AddÂ [rows to show | update]Â to detail as continuous value.

If you donâ€™t have the following: create a calculation calledÂ [TRUE]Â where the calculation isÂ TRUEÂ and calculation calledÂ [FALSE]Â that isÂ FALSE. Add these calculations to detail.

NowÂ update your shapesÂ with the following:

Assign Furniture the 3-bar menu, assign Office Supplies the 4-bar menu, and assign Technology the 5-bar menu. These correspond with the density of the charts.

Donâ€™t forget to also update the color so that the true value is a dark gray and the false value is a light gray. Remove borders and lines. Drop the category header, as well.

## Step #4: Build the dashboard

Add the two sheets to the dashboard. Iâ€™m placing the controls above the table, but they could go below as well. Format so the buttons are big enough to operate with. Iâ€™ve got left- padding on the dashboard at 325px (and the dashboard is 500px wide).

## Step #5: Build the interactivity

Now you will add interactivity with the controls. Youâ€™ll also add the automatic deselecting of marks.

Add a parameter action. When you select a value on the control update theÂ [rows to show]Â parameter with theÂ [rows to show | update]Â measure.

Also add a filter action. On select of the control sheet on the dashboard update the control sheet itself where TRUE is pushed to FALSE.

This produces the following dashboard:

So whats the final result with pagination and row density control?Â This table:

## What's next?

In the next posts, weâ€™ll dive into creating next-level filters for tables.

Do you have more questions about Tableau? Talk to our expert consultants today and have all your questions answered!

## More to explore

Alteryx

### Beyond The Data: Dipali Kendre, Senior DevOps Engineer

Microsoft Power Platform

### Migrating Queries From Power BI Desktop to Dataflows

Data Coach is our premium analytics training program with one-on-one coaching from renowned experts.