Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[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
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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.

View solution in original post

7 Replies
Anonymous
Not applicable
Author

use tmap since u could drag & drop row values and sum
Anonymous
Not applicable
Author

Output Schema:
0683p000009MDKt.png
Using tJavaRow
0683p000009MDKy.png
Anonymous
Not applicable
Author

Brilliant
Thank you
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

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.
Anonymous
Not applicable
Author

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
Anonymous
Not applicable
Author

ur Welcome 0683p000009MACn.png  Ricco,  if u implement casting in tjavarow, u could reduce that tConvertType Component also.