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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Talend BigDecimal Divide operation do not work!

I am trying to divide 2 integer values and result must be decimal
For exp : pageview (12) / sessions(5) = pageviewPerSession (2,4)
I am using tConvertType to convert from INT to float or INT to BigDecimal , 
If i use float Talend works fine but I see the result value as "2" at msSQL
If i use BigDecimal at tMap :  row13.pageview.divide(row13.session) gives me error (xception in component tMap_4
java.lang.NullPointerException). Also i tried (row13.pageview / row13.session) it says / is undefined.
I prefer BigDecimal because msSQL dataType is decimal(18,4), IF I choose float at msSQL there is no chance to give float(18,4) only float data type and it shows just "2" in my example.
Please help
Best Regards
Cihan

0683p000009MBLw.jpg
Labels (3)
1 Solution

Accepted Solutions
_AnonymousUser
Specialist III
Specialist III

Hi Cbehen,
The error is due to your first comparison with '0'. 
You already have converted    row13.session to Bigdecimal and now comparing with integer 0. Use below code to compare with decimal 0-
 row13.session== java.math.BigDecimal("0")
Hope it works.

Thanks,
Shruti

View solution in original post

3 Replies
Anonymous
Not applicable
Author

if you divide 2 integer values the result will always be an integer. You must cast at least one value to float and not only the result!
I suggest also use the type double instead of float!
Anonymous
Not applicable
Author

Hello I am converting INT to BigDecimal or INT to float at tConvertType before sending the data to the tMap
Problem here is sum of sessions are sometimes zero so when i try to divide pageviews/sessions gives me nullexception
This doesn't work : row13.session ==0?"do nothing":row13.pageview.divide(row13.session) 
Error message : Incompatible operand types BigDecimal and int.
There is no double datatype at msSQL so i am trying to do this division by using BigDecimal.
_AnonymousUser
Specialist III
Specialist III

Hi Cbehen,
The error is due to your first comparison with '0'. 
You already have converted    row13.session to Bigdecimal and now comparing with integer 0. Use below code to compare with decimal 0-
 row13.session== java.math.BigDecimal("0")
Hope it works.

Thanks,
Shruti