Contact

DVAR in ONLYOFFICE: Sample Variance for a Database Subset

Database Intermediate ONLYOFFICE

Calculate conditional sample variance, audit n minus one, and distinguish squared units, singleton behavior and typed-array caveats.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: =DVAR(A1:D6,"Amount",Q1:Q2) has the independent target 100 for East values 10,20,30. The squared deviations total 200 and the sample divisor is 3−1=2.

Syntax and arguments

=DVAR(database, field, criteria)

Database includes its first-row headers. Field is a quoted header or a one-based column position within that database. Criteria is a separate block with recognized headers and at least one condition row. The official help documents this three-argument interface. Keep headers unique in the database and copy criteria headers exactly.

Build the database and criteria blocks

Create a blank sheet named DatabaseChecks. Enter this database in A1:D6, including the header row. Entries marked empty must be genuinely empty cells, not the word “empty”, a space or a formula returning empty text.

Row A: ID B: Team C: Amount D: Note
2 101 East 10 ready
3 102 West 40 ready
4 103 East 20 empty
5 104 East 30 hold
6 105 North 0 ready

These are fictional records. Amount is deliberately numeric, including a genuine zero. Note provides a separate text/blank field for count comparisons. Headers are unique and consistent.

Build these separate criteria blocks; none overlaps A1:D6:

Purpose Exact entries Range
East only Q1 Team; Q2 East Q1:Q2
East AND amount at least 20 F1 Team; G1 Amount; F2 East; G2 >=20 F1:G2
East OR West I1 Team; I2 East; I3 West I1:I3
No matching team K1 Team; K2 South K1:K2
All records M1 Team; M2 genuinely empty M1:M2
Unique ID 103 O1 ID; O2 numeric 103 O1:O2
Unique ID 105 S1 ID; S2 numeric 105 S1:S2

Enter >=20 as criterion text, not a formula. Place result formulas in U2:U15, outside every data/criteria block. The extra spaces used in this explanation are not part of the header text.

Rebuild the numerator and divisor

The mean is 20. Compute (10−20)^2+(20−20)^2+(30−20)^2=200. Sample variance is 200/2=100. It is not 200/3, which would be population variance, and it is not 10, which is the square root of the sample variance.

For a transparent worksheet check, enter 10,20,30 in W2:W4, calculate their mean in Y2, and fill =(W2-$Y$2)^2 down X2:X4. =SUM(X2:X4)/(COUNT(W2:W4)-1) has target 100. This independently reconstructs the clean numeric example without pretending to execute DVAR.

Worked subset comparisons

Formula Target
=DVAR(A1:D6,"Amount",Q1:Q2) 100
=DVAR(A1:D6,3,F1:G2) 50
=DVAR(A1:D6,"Amount",I1:I3) 166.666666666667
=DVAR(A1:D6,"Amount",M1:M2) 250

For 20,30, the mean 25 gives squared-deviation sum 50 and divisor 1. For 10,40,20,30, sum 500 is divided by 3. All five values, including the genuine zero, have mean 20 and sum 1000, divided by 4. A blank criterion changes the population being selected; it does not remove zero observations.

Advanced: units and transformations

If Amount is measured in hours, DVAR is in hours squared. Its square root is the clean numeric sample standard deviation from DSTDEV. Do not label a variance result as an ordinary number of hours.

Adding 50 to every selected value preserves variance because deviations from the new mean are unchanged. Multiplying each value by 10 multiplies variance by 100, not 10. For the East data, the independent rescaled target is 10000. These identities are useful mathematical checks, but they do not validate the criteria selection or imported cell types by themselves.

DVARP uses divisor n and has East target 200/3. A larger sample variance is a denominator consequence, not evidence that the same records were filtered differently.

Source-level singleton and mixed-type limits

No South match returns #DIV/0! in the explicit source branch. A single numeric value produces zero squared deviation divided by n−1=0; the nonfinite result is converted by the number constructor to #NUM!. That singleton result is a source prediction for this revision, not a generic cross-product rule.

The aggregation initially collects numeric typed values and propagates errors. However, its squared-deviation loop uses the original selected-array length, not the filtered numeric-array length. A retained nonnumeric value can therefore lead to an undefined array entry and NaN rather than being safely ignored. Do not teach universal text exclusion from this code. Keep Amount genuinely numeric and treat mixed-type data as a separate regression case.

A record with an empty selected field can be removed earlier by the shared helper, potentially yielding #DIV/0! before the variance code runs. Distinguish that from a valid matching numeric singleton; a single error message cannot replace checking the selected records and their types.

Criteria logic and important ONLYOFFICE source limits

Conditions in one criteria row are combined with AND; separate rows supply OR alternatives. The first main OR row above matches East, and the second matches West. A record matching both alternatives is collected once in the inspected helper.

A blank criterion means no restriction for that column in the checked source. Thus M1:M2 selects all records; it is not a request to find blank Team cells. An accidental blank OR row can similarly broaden the selection. Keep the criteria rectangle tight rather than including unused rows for convenience.

Bare text is another trap: the helper appends a wildcard to a text criterion without an operator. East can therefore match a longer prefix such as Eastside. This database contains no such team, so the main results are unambiguous. To request explicit equality in a future test, store =East as text, for example by typing a leading apostrophe before it; do not accidentally enter it as a formula. Wildcard, case and locale edge behavior needs its own bounded validation.

There is also a version-specific OR caveat. The inspected helper can return early when the first recognized criteria row has no matches, before considering later OR rows. Do not promise order-independent OR behavior from this implementation. Reversing a deliberately unmatched first row and a matching second row is a separate source-predicted regression probe, not a native test performed here.

Unknown criterion headers are not a safe way to request “no match”: the helper skips unrecognized headers and, if none are recognized, can select every record. Copy valid headers exactly and distinguish a misspelled criterion heading from an unknown selected field. These observations come from the shared source helper, not from applying another product’s database-function rules.

DPRODUCT, DSTDEV, DSTDEVP, DVARP provide related database aggregations. DAVERAGE describes the selected mean, DCOUNT helps audit clean numeric counts, and DSUM adds selected values.

Availability, compatibility and verification

The function is currently documented in ONLYOFFICE’s unversioned Spreadsheet Editor help. Its first introduction release/date, final supported version and any retirement announcement are not established by these sources. Documentation presence does not establish support in every older Desktop Editors build, Docs deployment or mobile client.

This guide checks official SDKJS tag v10.0.0.169, commit 3679e0375a758d7dc59d31337a45461be3525ed8, alongside current help on October 18, 2026. Main arithmetic is independently calculated; implementation-specific branches are labeled source-predicted. No ONLYOFFICE engine or application was executed for these examples. No native screenshots or recalculated workbook are claimed.

Formulas use English names and comma separators. Adapt separators to the actual editor locale. Similar function names elsewhere do not guarantee identical criteria matching, text coercion, errors or blank-field handling. Keep the database header in the formula range and preserve genuinely empty cells when transferring the example.

References checked October 18, 2026