Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Darmesh
Contributor III
Contributor III

how to do division in Talend

0683p000009LzRs.png

 

How to to division (i.e)

(row1.oper_exp/row1.net_sales)*100

Labels (2)
3 Replies
Jesperrekuh
Creator III
Creator III

You just answered your own question in the same post 0683p000009MA9p.png
Keep in mind the nullpointerexception, which will be raised if one of your variables is null.

row1.OPER_EXP == null || row1.NET_SALES == null ? null : (row1.OPER_EXP /row1.NET_SALES )*100

Your columns are also defined in UPPERCASE and the formula lower case... Talend (java) is case sensitive

Darmesh
Contributor III
Contributor III
Author

@Dijke

         0683p000009LzME.png0683p000009LzSR.pngBut still it is throwing error

Jesperrekuh
Creator III
Creator III

look at java docu : https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html
Example:

      // create 3 BigDecimal objects
      BigDecimal bg1, bg2, bg3;

      bg1 = new BigDecimal("16");
      bg2 = new BigDecimal("3");

      // divide bg1 with bg2 with 3 scale
      bg3 = bg1.divide(bg2, 3, RoundingMode.CEILING);

so:

row1.OPER_EXP.divide(row1.NET_SALES, 3, RoundingMode.CEILING)