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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
satyavar
Contributor III
Contributor III

[resolved] Substraction between 2 Big Decimal values

Hi All
I am struggling with a Mathematical operation in tMap. I have a need to subtract 2 Big Decimal values and convert the output to string.
Can someone please help me on how to achieve this?
Thanks
Kalyan
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

try this...  and note that the below is based on your wanting to subtract one big decimal value from another.  For the sake of making your coding cleaner you can break your equation (in tMap) into a couple of steps to assign values to be used by the above listed statement.
1) digDecimalValue will be the result of ...  row3.ATTRIB_24.multiply(row3.ATTRIB_14).divide(BigDecimal.valueOf(100.00))
2) String bigDecimalString = row3.ATTRIB_24.subtract(bigDecimalValue).toString();
Hopefully the above is what you are looking for.
 

View solution in original post

3 Replies
Anonymous
Not applicable

Hi Kalyan,
Would be interested in as to what all approaches did you try with?
& was it the 'subtracting' part or the 'converting' part that really posed the challenge?
MathurM
satyavar
Contributor III
Contributor III
Author

Hi Mathur, I tried the following and i get the error as below:
(row3.ATTRIB_24 -(row3.ATTRIB_24.multiply(row3.ATTRIB_14).divide(BigDecimal.valueOf(100.00))))
The operator - is undefined for the argument type(s) java.math.BigDecimal, java.math.BigDecimal
Anonymous
Not applicable

try this...  and note that the below is based on your wanting to subtract one big decimal value from another.  For the sake of making your coding cleaner you can break your equation (in tMap) into a couple of steps to assign values to be used by the above listed statement.
1) digDecimalValue will be the result of ...  row3.ATTRIB_24.multiply(row3.ATTRIB_14).divide(BigDecimal.valueOf(100.00))
2) String bigDecimalString = row3.ATTRIB_24.subtract(bigDecimalValue).toString();
Hopefully the above is what you are looking for.