DVAR Function in Excel: Sample Variance of Matching Records

DVAR Function in Excel: Sample Variance of Matching Records 1
⏱ 1 min readUpdated 5 October 2026

DatabaseLevel: ExpertAvailable in: Excel 2007+

In this article
  1. Syntax
  2. Examples
  3. Example 1
  4. DVAR in practice
  5. Where you will use it
  6. Worked example
  7. Mistakes people make
  8. Related functions

DVAR returns the sample variance for matching records. Like all D-functions it uses a database range and a criteria range you can edit on the sheet.

Advertisement

Syntax

=DVAR(database, field, criteria)
Argument What it means
database The table including headers
field Column name in quotes or its number
criteria Range with headers and conditions

Examples

Example 1

=IFERROR(DVAR(DB,"Sales",CHOOSE(A2,CritA,CritB,CritC)),"error "&ERROR.TYPE(DVAR(DB,"Sales",CHOOSE(A2,CritA,CritB,CritC))))

Result: 4500000. Database H1:J6 (North 12000, South 8000, North 15000, West 22000, South 9000) with three criteria blocks.

DVAR in practice

Where you will use it

  • Reports where users edit the criteria on the sheet
  • OR conditions on separate rows
  • Legacy templates

Worked example

Database H1:J6 (North 12000, South 8000, North 15000, West 22000, South 9000) with three criteria blocks.

CaseCriteriaFormulaResult
1Region = North=IFERROR(DVAR(DB,"Sales",CHOOSE(A2,CritA,CritB,CritC)),"error "&ERROR.TYPE(DVAR(DB,"Sales",CHOOSE(A2,CritA,CritB,CritC))))4500000
2Sales > 10000=IFERROR(DVAR(DB,"Sales",CHOOSE(A3,CritA,CritB,CritC)),"error "&ERROR.TYPE(DVAR(DB,"Sales",CHOOSE(A3,CritA,CritB,CritC))))26333333.33
3North OR South=IFERROR(DVAR(DB,"Sales",CHOOSE(A4,CritA,CritB,CritC)),"error "&ERROR.TYPE(DVAR(DB,"Sales",CHOOSE(A4,CritA,CritB,CritC))))10000000

Results calculated in Excel.

Mistakes people make

MistakeWhat to do instead
Criteria headers that don't matchHeaders must match the database exactly
One matching record for D-SD/VARSample versions need 2+ records (#DIV/0!)

DSUM · DAVERAGE · DCOUNT

📚 Part of the free Excel course: Beginner → Expert · Try it in the Formula Lab or ask the AI Helper.

Advertisement
✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free · AI can be wrong