Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Multiplication of values in tMap

Hello Community,

 

I am pretty new in Talend so this is probably a basic question:

 

In my If / Else Condition I can´t multiply the two values of column row15.price (Integer) and row15.PLN(Double) in the Expression builder. If I try to test it following Error occurs: 

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

 

row15.currency.equals("PLN") ? row15.price*row15.PLN : "AA" 

0683p000009M8sc.png

Labels (3)
1 Solution

Accepted Solutions
TRF
Champion II

You need to convert values from string to double:
Double.parseDouble(row15.price)*Double.parseDouble(row15.PLN)

View solution in original post

3 Replies
TRF
Champion II

For a ternary expression, both parts (if/else) result must have the same datatype.
Try to change "AA" by something like -1.0 to signify the currency wasn't equal to PLN.
Anonymous
Not applicable
Author

Hello TRF,

thank you very much for your answer. 

 

When I change the "(if/else) results" to the same Datatype (e.g. assigning it to one variable) it works but I still can´t do a multiplication because it reads everything as a String. If I build a sum of e.g. 3.9+3.9 = 3.93.89 as you can see in the picture. 

 

How can I check if something equals "PLN" in the currency and then do a proper multiplication of doubles if it does and "else" give back a double:

row15.currency.equals("PLN") ? row15.price*row15.PLN : row15.price

 

I really appreciate your help. Thank you!

0683p000009M8sE.png

 

 

TRF
Champion II

You need to convert values from string to double:
Double.parseDouble(row15.price)*Double.parseDouble(row15.PLN)