Calligra Sheets #NUM!: Repair an Invalid Factorial Input
For factorial calculations, validate what the input represents. A negative count is not repaired by making the displayed error disappear.
Evidence scope: reviewed October 21, 2026 against KDE’s Calligra source at commit 72123cc643f6625351139e7df294544255a1056f. The error outcomes below are source-inferred expectations, not observed application results. No Calligra installation or screenshot was used for this guide. English error strings are shown; localized displays may differ. This does not clear existing import failures or establish behavior in every packaged version.
Why this example returns a numeric error
The pinned FACT implementation accepts an integer value greater than or equal to zero and otherwise returns Calligra’s numeric error. Its English error definition is #NUM!. This is one supported cause, not a complete list of every function that can return that error.
Trace a count calculated in the wrong direction
Suppose a model calculates how many objects remain before counting their possible arrangements. Use small synthetic counts so the expected result is easy to check.
- Put
6in A2 for the starting count and2in B2 for the removed count. - Enter the deliberately reversed formula
=B2-A2in C2. The independently checked result is-4. - Enter
=FACT(C2)in D2. A negative argument fails the source’s non-negative requirement;#NUM!is the expected error category. - Correct C2 to
=A2-B2. It should now hold4, and D2 should produce24, since 4 × 3 × 2 × 1 = 24. - Change B2 to
3. The corrected count becomes3and the expected factorial becomes6. Restore2after the change test.
Reversing C2 again in a scratch copy recreates the bad input. Keep the repaired formula, rather than typing 24 into D2.
Choose the right correction
This repair is valid only because the model really means starting count minus removed count. If the removed count is genuinely larger than the starting count, check the data or business rule instead. Do not automatically wrap the count in ABS: that would turn an impossible shortage into a positive count without explaining it.
Likewise, do not round a fractional input just to obtain a factorial. Decide whether the source should be a whole-number count and why a fraction appeared. This guide does not promise that every numeric storage type or imported fractional value is coerced identically; the source condition is specifically an integer value.
The FACT function reference covers the function’s normal use. For prevention, data validity can help document intended input rules, but a rule does not independently prove a count is factually correct.
Check before returning to the workbook
Verify the intermediate count as well as the final answer. If the intermediate result remains stale after a correction, follow recalculation checks. Retain the failing example, original formula and repaired formula in a separate test copy when investigating a version difference.
Do not assume a different #NUM! formula has the same cause. Identify its function and argument requirements first, using the error selector and function directory.