cancel
Showing results for 
Search instead for 
Did you mean: 

XI Math Results Incorect with More Than One Record

Former Member
0 Kudos

I do a Price-RemoveContexts-Sum-Add to existing amounts in my XI math calculation. It works perfect when testing a single record. It adds all of the correct values and gives the correct sum amount.

However, when testing with multiple records in a file the values are incorrect. Is there an XI function I am missing that may easily remedy this problem?

I did an a SplitByValue that worked but affected another mapping's result negatively in the file so I removed it.

Not sure my problem will be that easy to fix.

Thank-You.

Message was edited by:

Tom M.

Accepted Solutions (1)

Accepted Solutions (1)

former_member214364
Active Contributor
0 Kudos

Hi Tom,

if you want to add all prices under each Records then you can use removeContext.

i.e <Records>

<ParentNode>

<Price>1</Price>

<Price>2</Price>

<Price>3</Price>

</ParentNode>

<ParentNode>

<Price>4</Price>

<Price>5</Price>

<Price>6</Price>

</ParentNode>

<ParentNode>

<Price>7</Price>

<Price>8</Price>

</ParentNode>

<Records>

in the above example if you use removeContext for <b>Price</b> element,you will get <b>sum</b> function output value 36,its sum of all price values.

i Guess now you r clear with removeContext node function.

Cheers,

Jag

Answers (3)

Answers (3)

former_member214364
Active Contributor
0 Kudos

Hi Tom,

If you have price element in structure as follows

Records 1….Unbounded

ParentNode 1…1

Price 1…Unbounded

then you don’t have to use “removeContext” node function.

If you have structure as follows.

Records 1….Unbounded

ParentNode1 1…Unbounded

Price 1…1

Then also you don’t have to use “removeContext” node function. You just right click on “Price” node in Data flow editor and change context to “Records”.

Cheers,

Jag

Former Member
0 Kudos

How about if both ParentNode and Price are 1....unbounded. Then RemoveContext for Price? Thanks.

henrique_pinto
Active Contributor
0 Kudos

Tom,

again, please, enter your source and target messages.

Regards,

Henrique.

VijayKonam
Active Contributor
0 Kudos

I believe, RemoveContext function is making the difference here. Since it is working fine with one record, you did not have any problems with the mapping as there is only one record and all of them are added to one value. But when you have multiple records, and the Remove Contexts function works on all of the values at the message level, and hence, it will add the values of all the records (since now thy are under the message level contexts).

I sense, if you remove the remove context function and just map the repeating source element to the target element, it should solve the problem.

Vijay

henrique_pinto
Active Contributor
0 Kudos

What incorrection?

It seems the values arent been added at all, or you have decimal algharisms error (like it was supposed to be 4.56 but was 4.53)?

Regards,

Henrique.

PS: Also, please send us the source and target Message structures, since mapping functions will depend on the structure. See, you only need RemoveContext if you have a tag over the Price tag. But you'll also need some treatment to create the tags in target (as for example CollapseContext, etc).

Just send us the message types and we'll try to sort it out.