Contact

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.

  1. Put 6 in A2 for the starting count and 2 in B2 for the removed count.
  2. Enter the deliberately reversed formula =B2-A2 in C2. The independently checked result is -4.
  3. Enter =FACT(C2) in D2. A negative argument fails the source’s non-negative requirement; #NUM! is the expected error category.
  4. Correct C2 to =A2-B2. It should now hold 4, and D2 should produce 24, since 4 × 3 × 2 × 1 = 24.
  5. Change B2 to 3. The corrected count becomes 3 and the expected factorial becomes 6. Restore 2 after 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.