How to Calculate Covariance in Excel – Covariance Function

How to Calculate Covariance in Excel

Are you looking to calculate the covariance between two sets of data in Excel? Did you know that one of Excel's most powerful functions can unlock hidden relationships and patterns in numeric data, revolutionizing the way you analyze information?

Welcome to the Wisesheets, your ultimate guide to mastering Microsoft Excel and unleashing its full potential! In this article, we will dive into one of the fundamental statistical concepts – calculating covariance in Excel.

Whether you're a seasoned Excel user looking to enhance your data analysis skills or a beginner eager to explore the world of statistics, this step-by-step guide will walk you through the process of using the COVARIANCE function in Excel.

So get ready to elevate your Excel proficiency and estimate the linear relationship between two variables like a pro!

Table of Contents

How to Calculate Covariance Using Wisesheets

To calculate covariance using Wisesheets, you would need to utilize the built-in statistical functions available in Excel or Google Sheets. These functions include COVARIANCE.P, COVARIANCE.S, and COVAR, depending on the specific version of Excel or Google Sheets you are using.

You can use the retrieved stock price data from Wisesheets, combine it with other relevant financial data, and then use the appropriate covariance function within Excel or Google Sheets to calculate the positive or negative covariance between different stocks or other financial variables.

Covariance Syntax in Excel

There are several ways to calculate covariance in Excel, including using the COVARIANCE.P function or the Data Analysis Toolpak. By assessing the degree of their co-movement, you can gain valuable insights into their relationship – whether they tend to increase or decrease simultaneously or move in opposite directions.

Prepare your data

Before calculating covariance in Excel, it is important to ensure that your data is properly prepared. Follow these steps to prepare your data.

Prepare your data

Organize: Make sure your data is carefully organized in columns, with each variable having its own column.

Enter: Input all the data accurately into Excel, ensuring that each variable is entered into its respective column.

Check for missing values: Scan your data for any missing values and decide on the appropriate method to handle them.

Ensure data types: Check that the data in each column is of the correct type.

By properly preparing your all the data, you will set a solid foundation for calculating covariance accurately in Excel.

How to Calculate Covariance in Excel? : Step-by-Step Guide

To calculate covariance in Excel, follow these steps:

Select the cell where you want the covariance result to appear.


Type "=COVARIANCE.P(" in the selected cell.

Select the input range for the first set of data: Click and drag to select the range of values for the first variable.

Type a comma (,) to separate the two ranges.

Select the range for the second set of data.

Covariance P formula

Close the parentheses and press Enter: Finish the formula by closing the parentheses and pressing Enter.


The covariance value will be calculated and displayed in the selected cell.


The COVARIANCE.S function in Excel calculates the sample covariance between the two random variables and returns the result. The syntax for the COVARIANCE.S function is as follows:

Type in "=COVARIANCE.S(array1, array2)"


array1 (required argument): This is the first range or array of values.

array2 (required argument): This is the second range or array of values.

If the given arrays contain text or logical values, they are ignored by the COVARIANCE in Excel function in such a scenario. The COVARIANCE.S function calculates the sample covariance.

The Covariance Formula

The covariance between two variables can also be calculated using the following formula.

Cov(X, Y) = Σ((X – μX) * (Y – μY)) / (n – 1)


Cov(X, Y) is the covariance between variables X and Y.

X and Y are the individual data points.

μX and μY are the means of variables X and Y, respectively.

n is the number of data points.

By using the covariance formula, you can manually calculate the covariance between two sets of data in Excel.

Using the Data Analysis Tool

Excel provides a Toolpak that includes various statistical functions, including covariance. To use the Toolpak to calculate covariance, follow these steps:

Enable the Data Analysis Toolpak: Go to the "File" tab, click on "Options," select "Add-Ins," and then click on "Excel Add-ins." Check the box for "Analysis ToolPak" and click "OK."

Data Analysis Toolpak

Once it is enabled, go to the "Data" tab in Excel.

data tab excel

Click on "Data Analysis": In the "Analysis" group, click on "Data Analysis."

Choose "Covariance": In the Data Analysis window, select "Covariance" and click "OK."

data tools excel

Input the ranges: In the "Covariance" dialog box, select the input range for the two data sets.

Select the output range: Choose the location where you want the covariance matrix to be displayed.

Click "OK": Click "OK" to calculate the covariance using the Toolpak. The covariance matrix will be generated in the selected output range.

Make Covariance Calculation a Breeze with Wisesheets

Mastering the Covariance Function in Excel is a game-changer for data analysis. By understanding the relationship between variables, you can make informed decisions and uncover valuable insights. Tools like Wisesheets, an Excel and Google Sheets add-on for stock investors further enhance your analytical capabilities by automating data retrieval and enabling custom modeling.

Unlock Excel's potential, calculate covariance effortlessly, and accelerate your success with Wisesheets. Start your journey today and experience the power of data-driven decision-making.


What is the Covariance Excel Function?

The Covariance Excel function is categorized under Statistical functions. It calculates the joint variability of two random variables given two data sets.

How can I prepare my data for accurate analysis in Excel?

To ensure accurate analysis, organize and clean your it to remove any duplicates or errors, and arrange it in a clear and structured format.

Where can I find more resources to enhance my Excel skills?

Earn & Excel offers a wealth of tutorials, landing pages, and blog posts dedicated to Excel proficiency and data analysis expertise. Dive in and unlock the full potential of Excel!

Are covariance and correlation the same in Excel?

No, they're different. Covariance indicates if two variables change together but doesn't show the strength of the relationship. Correlation measures both the direction and strength of the relationship between two variables. Both can be calculated in Excel using different functions.

Guillermo Valles

Guillermo Valles

Hello! I'm a finance enthusiast who fell in love with the world of finance at 15, devouring Warren Buffet's books and streaming Berkshire Hathaway meetings like a true fan.

I started my career in the industry at one of Canada's largest REITs, where I honed my skills analyzing deals and learning the ropes.

My passion led me to the stock market, but I quickly found myself spending more time gathering data than analyzing companies. That's when my team and I created Wisesheets, a tool designed to automate the stock data gathering process, with the ultimate goal of helping anyone quickly find good investment opportunities.

Today, I juggle improving Wisesheets and tending to my stock portfolio, which I like to think of as a garden of assets and dividends. My journey from a finance-loving teenager to a tech entrepreneur has been a thrilling ride, full of surprises and lessons.

I'm excited for what's next and look forward to sharing my passion for finance and investing with others!

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts