Bernard K

May 29, 2021

How to color specific columns and rows in Tableau crosstabs

Updated: Nov 7, 2022

When working with crosstabs, sometimes you might be interested in coloring specific columns or rows to emphasize on them. And therefore, in this short article I am going to share with you one way you can color certain rows and columns in your crosstabs.

But first…. Using Sample Superstore data, lets create a crosstab…

Showing Sub-category Sales for different years.

Since Tableau formatting options do not allow us to color specific row(s) and column(s), I am going to create a calculated field to achieve this. For example, using the above crosstab, I am going to color the Year 2019 using the following calculation.

(This calculation is assigning all orders made in the year 2019 the value 1 and the rest of orders the value 0)

Drag the above calculation ‘Color – order date’ to the color shelf, change the aggregation from SUM() to AVG().

Change the marks card from automatic to Square.

Chose a custom diverging color palette with two stepped color, assign the end with zero the background color of your worksheet (in this case white), and the other end with one the color you would like to use in coloring the column (in this case blue).

Executing this we have,

Note the same procedure applies when coloring the rows. For example, to color row containing ‘Paper’ I would use the following calculation.

You can also color both the rows and columns using a different calculation. For example, I can color the Year 2020 and product subcategory ‘Chairs’ using the following calculation.

Following the same procedure, I have.

You can also include parameters to empower users choose the row(s) and column(s) they would like to color in a more dynamic way.

Useful: Learn how to work with parameters in Tableau.

I hope this article was helpful to you. To receive more of the Tableau tips and tricks, kindly join our mailing list by subscribing below.

If you like the work we do and would like to work with us, drop us an email on our Contacts page and we’ll reach out!

Thank you for reading!