top of page
  • Bernard K

How to create correlation matrix/heatmap in Tableau

how to create correlation heatmap in tableau


Correlation is a statistic that measures the degree to which two variables move in coordination with each other. Where, if the two variables move in the same direction, then those variables are said to have a positive correlation. If they move in opposite directions, then they are said to have a negative correlation.

In Tableau, you can compute the correlation coefficient using these two functions.

  • CORR () – Which returns the Pearson correlation coefficient of two expressions.

  • WINDOW_CORR () – Which returns the Pearson correlation coefficient of two expressions within a window.

For example, using this sample data.

sample dataset

I can compute the Pearson correlation coefficient for two variables, Crime and Poverty using the calculation below.

correlation function in tableau

Adding this calculation to the label shelf.

Notice this value is equivalent to the square root of the R-squared value.

using trendline to compute correlation coefficient in tableau

(The R-squared value, is the square of the correlation)

Creating correlation heatmap in Tableau

To create a correlation heatmap using the same data, first I will need to shape the data by converting it from crosstab to columnar format.

Export now pivoted data and connect it in Tableau.

Add a second copy of the data set to the Tableau data source by relating the two using the common dimension ‘State’.

relating datasets in tableau

On a new worksheet, add the dimension ‘Var’ from the two tables to create the view below.

Compute the ‘Correlation Coefficient’ using the following calculation.

Drag the above calculation to the color shelf and show labels.

sample correlation matrix/heatmap

(This creates a correlation matrix – showing the correlation coefficients between variables in this sample data).

Combining correlation matrix and scatter plot in a dashboard

Note, you can combine the correlation matrix and scatter plot to create a cool dashboard that allows you experience seamless interactions between the variables as well as access more statistics.

combining correlation matrix and scatter plot in a tableau dashboard


I hope this article was helpful to you. If you wish to receive more 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!


Black & white.jpg

About Me

More About the Author

Bernard K

Analytics Consultant | 3X Tableau Certified

Bernard is a data analytics consultant helping businesses reveal the true power of their data and bring clarity to their reporting dashboards. He loves building things and sharing knowledge on how to build dashboards that drive better outcomes.

Let’s discuss your data challenges! Let’s work together!

bottom of page