<?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: Calculations in script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806392#M1212142</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thank you for your prompt reply.&lt;/P&gt;&lt;P&gt;It works but I have problem with non integers. Multiplication cannot be performed with non integers.&lt;/P&gt;&lt;P&gt;What could be the solution when Field_a would look like:&lt;/P&gt;&lt;P&gt;Field_a&lt;/P&gt;&lt;P&gt;9.81&lt;/P&gt;&lt;P&gt;8.8&lt;/P&gt;&lt;P&gt;4.8114&lt;/P&gt;&lt;P&gt;2.815&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Sun, 09 May 2021 11:17:20 GMT</pubDate>
    <dc:creator>AmCh</dc:creator>
    <dc:date>2021-05-09T11:17:20Z</dc:date>
    <item>
      <title>Calculations in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1805625#M1212073</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I have already imported those fields as an example:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Field_a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Year&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My ouput should look like:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Operation&lt;/STRONG&gt;:&lt;U&gt; If value (Field_a) &amp;gt;5&lt;/U&gt; &lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;then&lt;/FONT&gt; value(Field_b)=value(Field_a)*2*Year&lt;/FONT&gt; &lt;U&gt;else&amp;nbsp;&lt;/U&gt;&lt;FONT color="#FF0000"&gt;value(Field_b)=value(Field_a)*Year/2&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;NB: These operations should be performed in the script and not as a chart expression.&lt;/EM&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Year/Field _b&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help please?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 19:29:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1805625#M1212073</guid>
      <dc:creator>AmCh</dc:creator>
      <dc:date>2021-05-05T19:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1805630#M1212074</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;First attempt would be like this:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Fields:
load * inline [
Field_a
9
8
4
2
];

join(Fields)
Years:
load * inline [
Year
1
2
3
4
5
6
];

NoConcatenate
Result:
load Field_a, Year, if(Field_a &amp;gt; 5, Field_a*2*Year, Field_a*Year/2) as Field_b Resident Fields;

drop table Fields;&lt;/LI-CODE&gt;&lt;P&gt;This code will give you output like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mfchmielowski_0-1620243707659.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/54396i860462A062609A92/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mfchmielowski_0-1620243707659.png" alt="mfchmielowski_0-1620243707659.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But one thing is weird. The output format suggest that you want to have many columns named Field_b - that's impossible.&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 19:44:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1805630#M1212074</guid>
      <dc:creator>mfchmielowski</dc:creator>
      <dc:date>2021-05-05T19:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806392#M1212142</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thank you for your prompt reply.&lt;/P&gt;&lt;P&gt;It works but I have problem with non integers. Multiplication cannot be performed with non integers.&lt;/P&gt;&lt;P&gt;What could be the solution when Field_a would look like:&lt;/P&gt;&lt;P&gt;Field_a&lt;/P&gt;&lt;P&gt;9.81&lt;/P&gt;&lt;P&gt;8.8&lt;/P&gt;&lt;P&gt;4.8114&lt;/P&gt;&lt;P&gt;2.815&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sun, 09 May 2021 11:17:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806392#M1212142</guid>
      <dc:creator>AmCh</dc:creator>
      <dc:date>2021-05-09T11:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806408#M1212146</link>
      <description>&lt;P&gt;Hi, what is your source of thouse digits?&lt;BR /&gt;I've changed values in my inline load and it works correctly.&lt;/P&gt;</description>
      <pubDate>Sun, 09 May 2021 15:46:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806408#M1212146</guid>
      <dc:creator>mfchmielowski</dc:creator>
      <dc:date>2021-05-09T15:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806416#M1212150</link>
      <description>&lt;P&gt;The same with non integers:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Fields:
load * inline [
Field_a
9.8
8.8
4.8
2.8
];

join(Fields)
Years:
load * inline [
Year
1
2
3
4
5
6
];

NoConcatenate
Result:
load Field_a, Year, if(Field_a &amp;gt; 5, Field_a*2*Year, Field_a*Year/2) as Field_b Resident Fields;

drop table Fields;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;With the following output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AmCh_0-1620588242077.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/54576i878C857885698A1D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AmCh_0-1620588242077.png" alt="AmCh_0-1620588242077.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 May 2021 19:24:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806416#M1212150</guid>
      <dc:creator>AmCh</dc:creator>
      <dc:date>2021-05-09T19:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806468#M1212156</link>
      <description>&lt;P&gt;Hmm that's weird. Same loadScript on my qlik gives different results.&lt;BR /&gt;When you check the model with ctrl+t what qlikview says about type of Field_a ?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mfchmielowski_0-1620631446823.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/54590i14BE478790B128FE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mfchmielowski_0-1620631446823.png" alt="mfchmielowski_0-1620631446823.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm using polish language in qlik so presentation can be different but the $numeric info should be the same &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Maybe try to force this field with num#(Field_a) as Field_a in load.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 07:31:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806468#M1212156</guid>
      <dc:creator>mfchmielowski</dc:creator>
      <dc:date>2021-05-10T07:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806494#M1212164</link>
      <description>&lt;P&gt;ascii and text and it didn't work with num# as well.&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 08:30:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806494#M1212164</guid>
      <dc:creator>AmCh</dc:creator>
      <dc:date>2021-05-10T08:30:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculations in script</title>
      <link>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806528#M1212175</link>
      <description>&lt;P&gt;And what is the field type of field_a in model viewer?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 May 2021 09:16:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculations-in-script/m-p/1806528#M1212175</guid>
      <dc:creator>mfchmielowski</dc:creator>
      <dc:date>2021-05-10T09:16:39Z</dc:date>
    </item>
  </channel>
</rss>

