Skip to content

StoryTeller numeric repeater sort fails when any XPath value is NaN

Historical eraExstream StoryTeller repeater sorting

By Tomas Hajek, working with Exstream since 2008. Published 2026-05-28

Applies to: Exstream StoryTeller numeric repeater sorting over XPath 1.0; community-supplied mechanism, validate on your release.

Symptom

Numeric sorting on a repeater fails with Numeric sort with XPath 'field_name' encountered NaN value ''. Text sorting on the same repeater works. Wrapping the value in number(.) does not help when some records are empty or non-numeric, which is exactly when the error appears.

Cause

Numeric sorting converts every selected sort value to a number. An empty string or non-numeric text converts to NaN, and a single such row fails the whole sort.

Switching the sort type to text makes the error disappear, but that is not a fix: text ordering puts "10" before "9", so the output is now silently wrong instead of loudly broken. Loudly broken is the better of the two.

Fix

Guard the sort value and supply a deterministic fallback for invalid rows. The XPath 1.0 pattern reported for this:

value[number()=number()] | default

It works because NaN is the one value not equal to itself, so the number()=number() predicate filters out rows that fail numeric conversion, and the union with a default variable (typically 0) gives those rows a sortable value.

Two design decisions to make consciously:

  1. Should missing values sort first or last? Choose the fallback accordingly, before someone in production asks why the empty rows are on top.
  2. Is the fallback acceptable at all, or should the source data be repaired, or a dedicated always-present numeric sort field mapped instead? The upstream fix is more work and more durable.

Test with empty, non-numeric, negative, decimal, and duplicate values. This mechanism came from community experience, so validate it against the XPath implementation of your installed StoryTeller version before deploying it broadly.

Do not hide numeric errors with text sorting

Never use a text sort merely to suppress this error when the business rule requires numeric ordering. The error is telling you the data has rows that cannot be ordered numerically; the correct response is to decide what those rows should do, not to change the question.

Related Exstream notes.

Resolve can check the pattern against your environment.

Resolve searches your approved sources and shows its citations. If the evidence is weak, the same case reaches an experienced Exstream specialist with the evidence attached.

These articles describe field experience and identify the Exstream versions they cover. They are not official vendor guidance. CCMForge is independent and is not affiliated with or endorsed by OpenText. OpenText and Exstream are trademarks of their respective owner.