<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Nested calculation using BigDecimal in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294055#M66968</link>
    <description>&lt;BLOCKQUOTE&gt;
 JoRoesecke wrote:
 &lt;BR /&gt;Yes, definitely. Try this:
 &lt;BR /&gt;
 &lt;PRE&gt;((sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL)).compareTo(new BigDecimal(0)) == 0) ? (sort_APB_contr.TOT_BEDRAG_INCL_T_O__.subtract(sort_APB_contr.T_O_BEDRAG)).divide(sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL)) : 0 (change to the value to be returned)&lt;/PRE&gt;
 &lt;BR /&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;Hi Joachim,
&lt;BR /&gt;
&lt;BR /&gt;Tried this, but still got an error.
&lt;BR /&gt;
&lt;BR /&gt;I've now added extra steps where I first filter (tFilterRow) out the '0' rows and in a second map I perform the calculation. This way I do not have to test for the division by 0 in my calculation.
&lt;BR /&gt;
&lt;BR /&gt;Thanks once again for your assistance. Learned something new on adding tests in the calculations.
&lt;BR /&gt;
&lt;BR /&gt;Regards,
&lt;BR /&gt;Dave</description>
    <pubDate>Wed, 23 Nov 2016 14:47:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-11-23T14:47:29Z</dc:date>
    <item>
      <title>Nested calculation using BigDecimal</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294051#M66964</link>
      <description>&lt;P&gt;I would like some help with the syntax of current expression that I am trying to use in a tXMLMAP expression:&lt;BR /&gt;&lt;BR /&gt;(sort_APB_contr.TOT_BEDRAG_INCL_T_O__.subtract(sort_APB_contr.T_O_BEDRAG)).divide(sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL))&lt;BR /&gt;&lt;BR /&gt;I am getting the following error message: &lt;BR /&gt;"Exception in component tXMLMap_1&lt;BR /&gt;java.lang.ArithmeticException: Division undefined&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.math.BigDecimal.divide(Unknown Source)"&lt;BR /&gt;&lt;BR /&gt;Basically what I would like to accomplish is the following calculation:&lt;BR /&gt;(sort_APB_contr.TOT_BEDRAG_INCL_T_O__ minus sort_APB_contr.T_O_BEDRAG) divided by (sort_APB_contr.TOT_AANTAL_INCL_T_O__ minus sort_APB_contr.T_O_AANTAL)&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;Kind regards&lt;BR /&gt;Dave&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 11:17:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294051#M66964</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-23T11:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Nested calculation using BigDecimal</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294052#M66965</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;This usually means that you are trying to divide by zero. You will need to catch this. Example (not tested):&lt;BR /&gt;&lt;PRE&gt;sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL) != (new BigDecimal(0)) ? (sort_APB_contr.TOT_BEDRAG_INCL_T_O__.subtract(sort_APB_contr.T_O_BEDRAG)).divide(sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL)) : 0 (change to the value to be returned)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Let us know how this works out for you.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Joachim</description>
      <pubDate>Wed, 23 Nov 2016 11:36:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294052#M66965</guid>
      <dc:creator>JR1</dc:creator>
      <dc:date>2016-11-23T11:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Nested calculation using BigDecimal</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294053#M66966</link>
      <description>&lt;BLOCKQUOTE&gt;
  JoRoesecke wrote: 
 &lt;BR /&gt;Hi 
 &lt;BR /&gt; 
 &lt;BR /&gt;This usually means that you are trying to divide by zero. You will need to catch this. Example (not tested): 
 &lt;BR /&gt; 
 &lt;PRE&gt;sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL) != (new BigDecimal(0)) ? (sort_APB_contr.TOT_BEDRAG_INCL_T_O__.subtract(sort_APB_contr.T_O_BEDRAG)).divide(sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL)) : 0 (change to the value to be returned)&lt;/PRE&gt; 
 &lt;BR /&gt; 
 &lt;BR /&gt;Let us know how this works out for you. 
 &lt;BR /&gt; 
 &lt;BR /&gt;Regards, 
 &lt;BR /&gt;Joachim 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;Hi Joachim, 
&lt;BR /&gt; 
&lt;BR /&gt;Thanks for your quick reply. 
&lt;BR /&gt; 
&lt;BR /&gt;I implemented your statement and got the following message: 
&lt;BR /&gt; 
&lt;BR /&gt;Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type mismatch: cannot convert from Number&amp;amp;Comparable&amp;lt;?&amp;gt; to BigDecimal 
&lt;BR /&gt; 
&lt;BR /&gt;Could this be caused by the part&amp;nbsp; "!= (new BigDecimal(0)) ?" of your statement? 
&lt;BR /&gt; 
&lt;BR /&gt;Regards, 
&lt;BR /&gt;Dave</description>
      <pubDate>Wed, 23 Nov 2016 13:41:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294053#M66966</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-23T13:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Nested calculation using BigDecimal</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294054#M66967</link>
      <description>Yes, definitely. Try this:&lt;BR /&gt;&lt;PRE&gt;((sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL)).compareTo(new BigDecimal(0)) == 0) ? (sort_APB_contr.TOT_BEDRAG_INCL_T_O__.subtract(sort_APB_contr.T_O_BEDRAG)).divide(sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL)) : 0 (change to the value to be returned)&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Nov 2016 14:07:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294054#M66967</guid>
      <dc:creator>JR1</dc:creator>
      <dc:date>2016-11-23T14:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: Nested calculation using BigDecimal</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294055#M66968</link>
      <description>&lt;BLOCKQUOTE&gt;
 JoRoesecke wrote:
 &lt;BR /&gt;Yes, definitely. Try this:
 &lt;BR /&gt;
 &lt;PRE&gt;((sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL)).compareTo(new BigDecimal(0)) == 0) ? (sort_APB_contr.TOT_BEDRAG_INCL_T_O__.subtract(sort_APB_contr.T_O_BEDRAG)).divide(sort_APB_contr.TOT_AANTAL_INCL_T_O__.subtract(sort_APB_contr.T_O_AANTAL)) : 0 (change to the value to be returned)&lt;/PRE&gt;
 &lt;BR /&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;Hi Joachim,
&lt;BR /&gt;
&lt;BR /&gt;Tried this, but still got an error.
&lt;BR /&gt;
&lt;BR /&gt;I've now added extra steps where I first filter (tFilterRow) out the '0' rows and in a second map I perform the calculation. This way I do not have to test for the division by 0 in my calculation.
&lt;BR /&gt;
&lt;BR /&gt;Thanks once again for your assistance. Learned something new on adding tests in the calculations.
&lt;BR /&gt;
&lt;BR /&gt;Regards,
&lt;BR /&gt;Dave</description>
      <pubDate>Wed, 23 Nov 2016 14:47:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Nested-calculation-using-BigDecimal/m-p/2294055#M66968</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-23T14:47:29Z</dc:date>
    </item>
  </channel>
</rss>

