on 04-13-2011 1:36 PM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.