# How to Calculate and Use Correlation in Tableau using Aggregate Functions & Window Functions

How do you find and calculate correlation in tableau the best way to show this is with a scatter plot I have a scatter plot of sales and profit and you can see a trend line showing that the correlation between sales and profit is positive i've also created a calculation showing that the correlation is 0.047 you can also show the correlation in a title let's add a sheet and see how to calculate this in tableau. [Music] thank you correlation is a simple function and it is done at the row level so for each row in the data it grabs a correlation and Aggregates it so I'm going to create a calculation calculated field call it core one it's simply going to be four. As a function pass in your two variables so I'm going to pass in sales and profit click apply okay let's drag that into the view on text you can see that the correlation is 0.47 which is positive as sales goes up profit goes up the trouble with that calculation it's harder to use in sheets so I have a scatter plot built and if I grab my core one calculation put it on detail so I can add it to the title pass in core into my title make it core one. And you'll see that I get none Tableau is saying there is no correlation between sales and profit in my scatter plot even though I know correlation is 0.47 what Tableau is doing is correlation at the row level so for each dot for each point it was calculation calculating and correlation. Just a little bit differently by creating calculated field I'm going to call this window core one this time I'm going to Type window underscore core so window correlation it's a table calculation pass in sum of sales comma sum of profit these need to be aggregated within a window calculation within window core comply okay let's drag that onto detail double click on the title and pass that into the title. Click apply okay and you can see that the correlation is 0.47 in general if you want to use correlation in a sheet by itself you can just use the core function if you want to calculate the correlation in a scatter plot or in a different chart you're going to use a window core option hope this helps.