cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping issue

Former Member
0 Kudos

Hi All,

I have a input structure as below:

<row>

<item>10</item>

<value>100</value>

</row>

<row>

<item>20</item>

<value>140</value>

</row>

<row>

<item>30</item>

<value>200</value>

</row>

I want the sum of the values of the items not equal to 20. So I need the result

<result>300</result>

How can I achieve this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Chris,

This is very simple. Please follow the steps mentioned.

Need to Create an UDF of type All values of Queue.

Have three arguements, first item, second value, third removeContext(count(value))

In the UDF,

int counter = var3.length;

int sum = 0;

for(int i =0; i<counter ;i++)

{

if (var1<i> != 20)

sum + = var2<i>;

}

result.addValue(sum);

So,

Result in target field -> UDF[item,value,removeContext{count(value)}]

Cheers,

Souvik

Edited by: Souvik Chatterjee on Apr 13, 2011 6:15 PM

Former Member
0 Kudos

Sorry but I couldn't get it working.

I created UDF with 3 int inputs. UDF created as "All Values of Queue".

After that my first input is item.

Second input is value.

Third input is. value -> count -> removeContext ->

First the function gave errors and I fixed in as below:

for(int i =0; i<counter ;i++)

{

if (var1<i> != 20)

sum + = var2<i>;

But now it gives a error as below:

Error: For input string: "__cC_"

Can you help. Thanks.

Former Member
0 Kudos

hi..

use

item-> removeContext() -> UDF arguement1

value-> removeContext() -> UDF arguement2

value -> count -> removeContext -> UDF arguement3

Should work now!

Cheers,

Souvik

P.S. the bracket seems to disappear frm my code.

I had given if (var1 != 20) and sum + = var2 ;

think {} as third bracket as in arrays..

Edited by: Souvik Chatterjee on Apr 13, 2011 6:54 PM

Former Member
0 Kudos

It worked. Thank you very much.

Answers (1)

Answers (1)

Former Member
0 Kudos

This can be achieved with any UDF. Just use Std function as show below..

Use IfwithoutElse, equalS, Constant, NOT & sum function..

Logic: Set the context of Item & value to it's top level then

If>Not>Item>equalS>Constant(value 20)>Then(map value)>SUM-->Target.