DVARP Function for Conditional Variance in Google Sheets

Published on

This tutorial explains how to use the DVARP function to calculate the conditional variance of an entire population in Google Sheets.

Overview

The DVARP function calculates the variance, a measure of variability, based on a specified population. In Google Sheets, you can apply this function to a field containing multi-row records.

While it’s common to arrange your data in a database table format, it’s not strictly necessary in Google Sheets, as you can create virtual arrays to meet this requirement.

There are two database functions in Google Sheets for variance calculation: DVAR and DVARP. While DVAR is designed for use with a sample of the population, DVARP is intended for the entire population.

DVARP Function Syntax and Arguments

Syntax: DVARP(database, field, criteria)

Arguments:

1. Database

  • This is the range of data to consider. The first row must contain labels for each column.
  • For example, in the following table, the field labels are “Dog Breed,” “Height (mm),” and “Weight (lbs).”
Dog BreedHeight (mm)Weight (lbs)
Pug25414
Yorkshire Terrier2037
Papillon2034
French Bulldog30516
Labrador Retriever53359
Boxer53666
Pug28017
Pug26015
Pomeranian2035
Pomeranian1783
Pomeranian2797

If your data lacks field labels, you can specify them virtually within the formula.

2. Field

  • This indicates which column in the database to use for variance calculation. You can refer to it using either a text label or a numeric index (e.g., 2 for the “Height (mm)” column).

Example:

  • Text Label Method: =DVARP(database, "Height (mm)", criteria)
  • Numeric Index Method: =DVARP(database, 2, criteria)

3. Criteria

  • This specifies the conditions to filter the database before performing the calculation. At least one field label and one cell below it are required for the criteria range.
  • If your data is unstructured and lacks a header row, you may need to use a workaround to specify criteria.

Examples of the DVARP Function

Example Data

Consider the database shown above, which includes a list of dog breeds in column A, their heights in column B, and weights in column C. The total number of records is 12, including the header row.

Using the DVARP Function

To extract records for “Pomeranian” and calculate the variance of their height in millimeters, you can use the following formula:

  • Text Label Method:
    =DVARP(A1:C12, "Height (mm)", E1:E2)
  • Numeric Index Method:
    =DVARP(A1:C12, 2, E1:E2)
DVARP Function Example in a Database-like Table in Google Sheets

Multiple Criteria

To include both “Pomeranian” and “Yorkshire Terrier” in the criteria, add “Yorkshire Terrier” in cell E3 and modify the criteria range:

=DVARP(A1:C12, 2, E1:E3)

Specifying Criteria Within the Formula

You can also specify criteria directly within the DVARP formula:

=DVARP(A1:C12, 2, {"Dog Breed"; "Pomeranian"; "Yorkshire Terrier"})

For more information on using criteria, please refer to the Resources section at the bottom of this post.

Using DVARP Function with Missing Field Labels

If your data lacks field labels in the first row, the previous formulas may return a #VALUE! error. Here’s how to work around this:

=DVARP({" ", " ", " "; A2:C12}, 2, {" "; E2:E3})
DVARP Function Example Without Field Labels in Google Sheets

Criteria Hardcoded:

=DVARP({" ", " ", " "; A2:C12}, 2, {" "; "Pomeranian"; "Yorkshire Terrier"})

Here, we add virtual space characters as field labels.

Additional Notes

  1. Using DVARP Without Criteria:
    If you want to include all records in your calculation, specify one of the column references from the database. For example, to include all dog breeds, use:
    =DVARP(A1:C12, 2, A1:A12)
  2. Handling Blank Cells:
    The DVARP function will ignore records in the evaluation column that contain blank cells, text strings, TRUE, or FALSE. However, it will include zero values in the calculation.

Resources

You may find the following tutorial useful for further understanding:

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Hierarchical Numbering Sequences in Excel

Creating hierarchical numbering sequences in an Excel spreadsheet can significantly improve the way you...

How to Easily Repeat a Sequence of Numbers in Excel

Excel offers multiple ways to accomplish tasks, and the simplicity of each approach depends...

Create a Sequence of Dates at Every Nth Row in Excel (Dynamic Array)

Would you like to create a sequence of dates in every nth row in...

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.