DEVSQ Function in Calligra Sheets: Sum of Squared Deviations
Calculate the sum of squared deviations around the arithmetic mean with Calligra Sheets DEVSQ. Follow an audited worksheet and compare VAR and VARP.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Calligra Sheets. How formula examples are checked
Quick answer: DEVSQ totals the squares of the distances of numeric observations from their arithmetic mean. For valid real numbers, =DEVSQ(21;33;54;23) has the official documented result 684.75. It returns a sum of squared deviations, not an average, standard deviation or sample variance. [K1, K2, I1]
Validation (2026-10-13): Function-registration code, calculation-wrapper code, the KDE function handbook and XML were checked for pinned Calligra 26.08.2. Worked outputs below are independent calculations, not results observed in a running Calligra application. [K1โK5, I1]
Exact formula syntax and arguments
=DEVSQ(value1; [value2]; ...)
=DEVSQ(A2:A9)
=DEVSQ(21;33;54;23)
value1: required numeric observation, numeric cell reference, or range/array of observations. The C++ registration specifiessetParamCount(1,-1)and accepts arrays, so one formula argument may contain multiple observations. The XML handbook spells the variable-argument patternDEVSQ(value; value;...). [K1โK3]value2and later: optional additional numeric arguments/references/ranges. There is no optional divisor, sampling mode, mean, or rounding argument. The registration does not set a finite fixed upper bound; this is not proof that every installation accepts arbitrarily many arguments. [K2]- Output: one numeric squared-deviation sum for valid finite numeric inputs. Squared units apply: measurements in centimetres produce a result measured in cmยฒ. [K1, I1]
- Input conventions: KDE’s English examples separate arguments with semicolons (
;) and use a decimal point, with ranges writtenA2:A9. Parser changes under other locales have not been executed or confirmed. Brackets here document optional arguments; do not type the brackets into formulas. [K1] - No default mean: the function computes its own arithmetic mean over its accepted inputs. Its inspected wrapper passes the computed mean to an engine
arrayWalkoperation nameddevsq. Text, error-cell and Boolean coercion within that helper still requires native verification. [K3]
For numbers x1โฆxn with mean m = SUM(x)/n, the defining calculation is:
DEVSQ = (x1-m)^2 + (x2-m)^2 + ... + (xn-m)^2
Unlike sample variance VAR, it does not divide by nโ1; unlike population variance VARP, it does not divide by n. For well-formed numeric datasets, DEVSQ = VAR*(nโ1) = VARP*n. These relationships are independent mathematical identities, not observations from Calligra at runtime. [K1, K3, I1]
Step-by-step reproducible worksheet
- In a new sheet, enter A1 = Measurement and the following eight values in A2:A9 as numbers. Do not include a total or heading inside that range.
- Put H1 = Audit formulas and enter the formulas in H2:H13, keeping their destinations outside A2:A9.
- Increase displayed decimal places for the sample variance, and confirm that changing one A cell recalculates related formulas when tested in a native application; the numbers printed below are the independently calculated expectations. [I1]
| Cell | Numeric input | Cell | Numeric input |
|---|---|---|---|
| A2 | 2 | A6 | 5 |
| A3 | 4 | A7 | 5 |
| A4 | 4 | A8 | 7 |
| A5 | 4 | A9 | 9 |
| Enter in | Formula | Independently expected output | Why it matters |
|---|---|---|---|
| H2 | =DEVSQ(A2:A9) |
32 | Main squared-deviation sum. |
| H3 | =AVERAGE(A2:A9) |
5 | Mean of the eight values. |
| H4 | =COUNT(A2:A9) |
8 | Actual observation count. |
| H5 | =VAR(A2:A9) |
4.571428571429 | Sample variance = 32/7. |
| H6 | =VARP(A2:A9) |
4 | Population variance = 32/8. |
| H7 | =H5*(H4-1) |
32 | Recover sum from sample variance. |
| H8 | =H6*H4 |
32 | Recover sum from population variance. |
| H9 | =SUMSQ(A2:A9)-SUM(A2:A9)^2/COUNT(A2:A9) |
32 | Independent algebraic identity. |
| H10 | =DEVSQ(21;33;54;23) |
684.75 | KDE’s official literal-argument example. |
| H11 | =DEVSQ(-2;0;2) |
8 | Both signs contribute squared distances. |
| H12 | =DEVSQ(4;4;4) |
0 | No dispersion. |
| H13 | =DEVSQ(1;2;3) |
2 | Small exact sanity check. |
Audit the 32 by hand: the values have mean 5. Subtract 5 to obtain โ3,โ1,โ1,โ1,0,0,2,4. Squaring yields 9,1,1,1,0,0,4,16, adding to 32. In this dataset the population standard deviation is sqrt(32/8)=2 and sample standard deviation is sqrt(32/7)โ2.1380899353. [I1]
Advanced use 1 โ transparent per-row audit
Set B1 = Deviation and C1 = Squared deviation. Put =A2-$H$3 in B2 and copy through B9, then put =B2^2 in C2 and copy through C9. For A2:A9, the expected B values are โ3,โ1,โ1,โ1,0,0,2,4; the expected C values are 9,1,1,1,0,0,4,16. In H14, enter =SUM(C2:C9) โ 32. In H15, enter =H14/H4 โ 4; in H16, enter =H14/(H4-1) โ 4.571428571429. [I1]
The absolute $H$3 locks the mean while copying formulas; without it, the reference will move and the per-row comparison becomes invalid. A manual audit is useful when reviewing an outlier or checking whether text or missing data changed the set of accepted observations. It is not a substitute for checking native coercion behavior.
Advanced use 2 โ within-group versus overall variation
Place D2:D5 = 2,4,4,4 and E2:E5 = 5,5,7,9. The independent results are:
| Formula | Expected result |
|---|---|
=DEVSQ(D2:D5) |
3 |
=DEVSQ(E2:E5) |
11 |
=DEVSQ(D2:D5)+DEVSQ(E2:E5) |
14 |
=DEVSQ(A2:A9) |
32 |
Why 14 differs from 32: each group uses its own mean (3.5 and 6.5), whereas the combined observations use one overall mean of 5. This identity matters for grouping, ANOVA preparation and quality-control comparisons. Do not add within-group DEVSQ values and label them the total ungrouped variation. [I1]
Errors, boundaries, and troubleshooting
| Situation | What the examined evidence actually establishes | Recommended check |
|---|---|---|
| Zero dispersion | Independent arithmetic gives 0 for identical numeric observations; the calculation wrapper supports a deviation walk. | Verify =DEVSQ(4;4;4) natively. [K3, I1] |
| No accepted numeric observations | No explicit zero-count guard appears in func_devsq; behavior depends on avg and array-walk internals. No visible error string established. |
Test empty range and blank/text-only ranges. [K3] |
| Single accepted observation | Definition gives squared deviation 0 mathematically, but runtime and input coercion were not tested. | Test =DEVSQ(5) and =DEVSQ(A2) in the installed release. [I1] |
| Text, Boolean or blank cells | calc->avg(args,false) and arrayWalk(...,"devsq",...) are called, but we have not verified every type-filtering branch. |
Use a separate test sheet with one text, Boolean and empty cell each. [K3] |
| Referenced error cells | This wrapper does not document an application-visible error label. | Check error propagation with actual installed Sheets. [K3] |
| Too many formula arguments / extreme magnitudes | Registration gives variable arity, not an installed parser maximum; numerical precision/overflow was not benchmarked. | Keep numeric range compact; test unusual limits. [K2] |
| Formula displayed literally | A cell can be formatted as text, or syntax can differ from examples. | Verify leading = and local formula-entry settings. |
| Unexpected VAR comparison | VAR divides by nโ1 while VARP divides by n; a count of observations is not a count of arguments. |
Check COUNT, expected units and which population definition you intended. [I1] |
Native validation still required: zero/one/multiple observations, a range versus literal arguments, blank/text/Boolean cells, nested arrays and cell errors, locale separators, large numeric ranges, and function availability in a real installation. No native screenshots, parser executions or error-label claims are supplied here.
Compatibility, release, and limits
KDE registers DEVSQ as a distinct function in the 26.08.2 statistical module; DEVSQA is separately registered and uses a different deviation walk (devsqa) that needs its own type-specific review. These names describe distinct function variants. [K2, K3]
Microsoft’s Excel documentation also defines DEVSQ, but uses comma-separated syntax in its English examples and specifies Excel-specific argument and type-handling behavior. That document is evidence about Excel only, not proof that Calligra duplicates every Excel coercion rule or accepts a specific XLSX round-trip. The calculation is mathematically comparable for the numeric-only examples here. [M1, I1]
Version examined: KDE Gear/Calligra 26.08.2 (official announcement 2026-10-08) with source pinned at commit 72123cc643f6625351139e7df294544255a1056f. KDE’s Calligra download page points primarily to Linux distribution packages and Flatpak and says Windows support is under development. The registration confirms a shipped source implementation, not a native execution test on Linux/Windows. [K2โK5]
Related verified reference links
KDE documentation (opened 2026-10-13): AVERAGE โ mean, COUNT โ numeric observations, SUMSQ โ squared sum, VAR โ sample variance, VARP โ population variance, STDEV โ sample standard deviation, and STDEVP โ population standard deviation.
Claim-level references โ reviewed 2026-10-13
- [K1] KDE function handbook, DEVSQ meaning, semicolon syntax, numeric type and the 684.75 example: https://docs.kde.org/stable_kf6/en/calligra/sheets/functions.html#DEVSQ.
- [K2] Version-pinned KDE registration,
setParamCount(1,-1),setAcceptArray, DEVSQ versus DEVSQA: https://github.com/KDE/calligra/blob/72123cc643f6625351139e7df294544255a1056f/sheets/functions/statistical.cpp#L160-L171. - [K3] Pinned KDE implementation,
func_devsqandfunc_devsqa, mean and array-walk calls: https://github.com/KDE/calligra/blob/72123cc643f6625351139e7df294544255a1056f/sheets/functions/statistical.cpp#L1084-L1104. - [K4] Pinned KDE statistical XML, documented syntax, example and declared number parameters: https://github.com/KDE/calligra/blob/72123cc643f6625351139e7df294544255a1056f/sheets/functions/statistical.xml.
- [K5] Release and platform references, KDE Gear 26.08.2 (2026-10-08) and Calligra downloads: https://kde.org/announcements/gear/26.08.2/ ยท https://calligra.org/download/.
- [M1] Microsoft Excel DEVSQ documentation, comparison only: https://support.microsoft.com/en-us/excel/functions/devsq-function.
- [I1] Independent arithmetic, 2026-10-13: Python
statisticsmean/variance and a separate centered-squares identity were used to check table values and rounding. Not native Calligra execution.