Skip to Content

Sum of Double value in Xpath

Hi,

In 12.2, we have an issue in SUM function in XPATH in transaction. Sum function is working fine for small double values but for large double values has exp it is showing value as NA.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<Rowsets DateCreated="2013-09-26T13:36:30" EndDate="2010-12-22T14:31:00" StartDate="2010-12-22T14:31:00" Version="12.1">

<Rowset>

<Columns>

<Column Description="" MaxRange="1" MinRange="0" Name="DoubleCol" SQLDataType="8" SourceColumn="DoubleCol"/>

</Columns>

<Row>

<DoubleCol>2.160445391E7</DoubleCol>

</Row>

<Row>

<DoubleCol>5.460645391E7</DoubleCol>

</Row>

</Rowset>

</Rowsets>

For this XML as input param xmlin and in transaction, if we are using

Transaction.xmlin{sum(/Rowsets/Rowset/Row/DoubleCol)}

it is giving value as NA. But if DoubleCol value is small (like 10000,20000), it is showing sum result.

How to solve this issue.

Regards,

Senthil

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 27, 2013 at 06:56 AM

    Hi Senthil,

    XPATH's 'sum' function does not recognize '5.460645391E7' format of number.

    You can use 'Aggregate Statistics' action block under XML functions and get the 'Total' from its output, and check if it is giving you correct results.

    Hope this helps you!!

    Warm Regards,

    Anuj

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 27, 2013 at 09:12 AM

    Hi Senthil,

    As suggested by Anuj, the sum function of XPATH does not understand this exponential number format. So, using Aggregate Statistics is a good option here. I tried it and it works fine.

    Is there any specific reason to use XPATH? Or else, switching to this would be a good idea.

    Regards,

    Saumya Govil

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 27, 2013 at 07:40 PM

    Addressing the scientific notation at the source would be the best, but of course depends on how much control you have over the 'xmlin' property for your transaction. If you can't rely on this and use the simple xpath sum, then one option could also be using a calculated column action block to add number(DoubleCol) to the dataset of your xmlin property value. The xpath sum should easily work from that resultset and in case you need to do any other work with the resultset coming into the transaction you always have both the original and the adjusted values for each row.

    Regards,

    Jeremy

    Rapid Innovation Group (RIG)

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.