Sorting repeater on Storyteller by numeric - Encountered NaN value

Simone Bissi
Simone Bissi Member
edited May 30 in Exstream #1

Hi all.

I set a numeric sort order on a field of a repeating block. During testing I get the error: "Numeric sort with XPath 'field_name' encountered NaN value ''."
If I set the sorting as Text type it works instead.
In XMLIN I didn't initially set any function or format for that field. Even if I set the number(.) function in the Value field, however, I get the same error.
Where am I wrong?

Thanks

Best Answer

  • dba01
    dba01 E Member
    #2 Answer ✓

    Numeric sorting on a repeater requires that every sort value is a valid number.

    If that is not the case, you receive the above reported message.

    You can try to fix your data, or change the sort key definition like this:
    value[number()=number()] | default

    Numeric sort turns the value into a number. In case of multiple element in node set, it takes the first value.

    To test if value is a valid number in XPath 1.0, AI suggests to use number() = number() condition which is false for NaN.

    For default value you can use for example variable $default = 0;

    Dave Bares
    Product Manager

Answers

  • Hello, can someone answer me please? thanks

  • Karen Weir
    Karen Weir E Community Administrator

    @Simone Bissi , I have moved your post over to our Exstream category so that it gets the best experts to review.

  • dba01
    dba01 E Member
    #5 Answer ✓

    Numeric sorting on a repeater requires that every sort value is a valid number.

    If that is not the case, you receive the above reported message.

    You can try to fix your data, or change the sort key definition like this:
    value[number()=number()] | default

    Numeric sort turns the value into a number. In case of multiple element in node set, it takes the first value.

    To test if value is a valid number in XPath 1.0, AI suggests to use number() = number() condition which is false for NaN.

    For default value you can use for example variable $default = 0;

    Dave Bares
    Product Manager