One Star

[resolved] Addition and Subtraction

Hello 
Can someone help me please?
I have some data in 4 columns that I need to perform some calculations on.
ID   Col1   Col2   Col3   Col4
1     100    150     8      25
2     200    250     9      35
3     150    175     8      27
What I need to do is this simple ecquation
Col1 + Col2 + (Col3 * Col4)
Is this possible to achieve using tJavaRow? is it easier using an Expression within tMap? 
I have tried to do this within tJavaRow creating a variable and assigning the equation to the variable but it doesn't like my '+' and '*'. Can someone tell how to achieve this using Java please?
Thank you
Ricco
1 ACCEPTED SOLUTION

Accepted Solutions
One Star

Re: [resolved] Addition and Subtraction

Its ok, I have cracked it.
I have the following
tMap --> tConvertType --> tJavaRow --> tLog
tmap created the addition column.
tConverType convert column 3 to a bigdecimal
tJavaRow dows the calculation and assigns the result to the column i.e
output_row.Column5 = input_row.col1.add(input_row.col2.add(input_row.col3.multiply(imput_row.col4)));
The result is printed in the tLogRow.
Thanks everyone for your inspiration.
7 REPLIES

Re: [resolved] Addition and Subtraction

use tmap since u could drag & drop row values and sum

Re: [resolved] Addition and Subtraction

Output Schema:

Using tJavaRow
One Star

Re: [resolved] Addition and Subtraction

Brilliant
Thank you
One Star

Re: [resolved] Addition and Subtraction

Something else I failed to mention.
3 of the columns (1,2 and 4) are all BidDecimals and column 3 is an integer.
Can anyone help me calculate based on this criteria?
Thanks
One Star

Re: [resolved] Addition and Subtraction

Its ok, I have cracked it.
I have the following
tMap --> tConvertType --> tJavaRow --> tLog
tmap created the addition column.
tConverType convert column 3 to a bigdecimal
tJavaRow dows the calculation and assigns the result to the column i.e
output_row.Column5 = input_row.col1.add(input_row.col2.add(input_row.col3.multiply(imput_row.col4)));
The result is printed in the tLogRow.
Thanks everyone for your inspiration.
One Star

Re: [resolved] Addition and Subtraction

Hi ,
Try with below one without tConvertType:
output_row.Column5 = input_row.col1.add(input_row.col2.add((BigDecimal.valueOf(input_row.col3.multiply))(imput_row.col4)));
Regards,
Kumar

Re: [resolved] Addition and Subtraction

ur Welcome Smiley Happy  Ricco,  if u implement casting in tjavarow, u could reduce that tConvertType Component also.