<?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 String Calculation Evaluation in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234787#M86114</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check Evaluate() function. Here is a sample for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;SourceTab:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;item, calc&lt;BR /&gt;A, 20+10+2&lt;BR /&gt;B, 15+3&lt;BR /&gt;];&lt;BR /&gt;TargetTab:&lt;BR /&gt;Load item,&lt;BR /&gt; evaluate(calc) as calc_result&lt;BR /&gt;resident SourceTab;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Feb 2010 17:00:47 GMT</pubDate>
    <dc:creator>disqr_rm</dc:creator>
    <dc:date>2010-02-09T17:00:47Z</dc:date>
    <item>
      <title>String Calculation Evaluation</title>
      <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234786#M86113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a field in a SQL table that contains a string representing a calculation. I.e.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;item&lt;/TD&gt;&lt;TD&gt;calc&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;20+10+2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;15+3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;In the example, for Item A, '20+10+2' is the text value of field 'calc'&lt;/P&gt;&lt;P&gt;I need to evaluate in the script this calculation to another field with the result ( 32 for item A, 18 for item B).&lt;/P&gt;&lt;P&gt;I wanted to do that in the LOAD or SELECT sentence, avoiding further loops inside each record. I have tried both Evaluate function and $ expansion, but both don't work, resulting in a script crash. I understood that Evaluate function does not accept string value.&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Paolo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2010 16:48:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234786#M86113</guid>
      <dc:creator />
      <dc:date>2010-02-09T16:48:27Z</dc:date>
    </item>
    <item>
      <title>String Calculation Evaluation</title>
      <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234787#M86114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check Evaluate() function. Here is a sample for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;SourceTab:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;item, calc&lt;BR /&gt;A, 20+10+2&lt;BR /&gt;B, 15+3&lt;BR /&gt;];&lt;BR /&gt;TargetTab:&lt;BR /&gt;Load item,&lt;BR /&gt; evaluate(calc) as calc_result&lt;BR /&gt;resident SourceTab;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2010 17:00:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234787#M86114</guid>
      <dc:creator>disqr_rm</dc:creator>
      <dc:date>2010-02-09T17:00:47Z</dc:date>
    </item>
    <item>
      <title>String Calculation Evaluation</title>
      <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234788#M86115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, this is the first solution I tried, but the script fails. I suspect this is because this field is coming from a SQL table as a varchar and this is not the correct use of evaluate() function.&lt;/P&gt;&lt;P&gt;In fact, &lt;EM&gt;evaluate(20+10+2)&lt;/EM&gt; is working, but &lt;EM&gt;evaluate(calc),&lt;/EM&gt; where calc='20+10+2' does not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 23:49:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234788#M86115</guid>
      <dc:creator />
      <dc:date>2010-02-10T23:49:57Z</dc:date>
    </item>
    <item>
      <title>String Calculation Evaluation</title>
      <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234789#M86116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I see. Well you can try to play with the contents ad see how it goes. I would try somethinglike below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;Data:&lt;BR /&gt;Load item,&lt;BR /&gt;evaluate(trim(text(calc))) as calc_result;&lt;BR /&gt;SELECT * from SqlTable;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Feb 2010 23:59:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234789#M86116</guid>
      <dc:creator>disqr_rm</dc:creator>
      <dc:date>2010-02-10T23:59:06Z</dc:date>
    </item>
    <item>
      <title>String Calculation Evaluation</title>
      <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234790#M86117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is not working as well, I keep trying with every combination...&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Feb 2010 11:39:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234790#M86117</guid>
      <dc:creator />
      <dc:date>2010-02-11T11:39:57Z</dc:date>
    </item>
    <item>
      <title>String Calculation Evaluation</title>
      <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234791#M86118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;﻿in qv 10 sr3 it is now working with the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let vTest = 1;&lt;/P&gt;&lt;P&gt;Calc:&lt;/P&gt;&lt;P&gt;load *, Evaluate(formula) as EvalCalc INLINE [&lt;/P&gt;&lt;P&gt;Key;formula&lt;/P&gt;&lt;P&gt;1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vTest+10+2&lt;/P&gt;&lt;P&gt;2;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;15+3&lt;/P&gt;&lt;P&gt;](delimiter is ';');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which evaluates to 13 and 18 in a table view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But what if we want to evaluate field values? has anyone succeeded?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ex;&lt;/P&gt;&lt;P&gt;let vTest = 1;&lt;/P&gt;&lt;P&gt;Calc:&lt;/P&gt;&lt;P&gt;load *, Evaluate(formula) as EvalCalc INLINE [&lt;/P&gt;&lt;P&gt;Key;formula&lt;/P&gt;&lt;P&gt;1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vTest+10+2&lt;/P&gt;&lt;P&gt;2;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;15+3&lt;/P&gt;&lt;P&gt;3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Key+10+2 &lt;/P&gt;&lt;P&gt;](delimiter is ';');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The field Key in the fomula will not evaluate to 3 but instead shows nothing.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="evaluateTable.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/8615_evaluateTable.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 16:40:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234791#M86118</guid>
      <dc:creator />
      <dc:date>2011-11-14T16:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: String Calculation Evaluation</title>
      <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234792#M86119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We are just discussing this problem here:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/message/164822#164822"&gt;http://community.qlik.com/message/164822&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My suggestion would be to use replace function to put the field values into EvalCalc string before calling evaluate().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit:&lt;/P&gt;&lt;P&gt;In the meanwhile, much better solutions were posted, I redraw my suggestion &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 16:49:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234792#M86119</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2011-11-14T16:49:15Z</dc:date>
    </item>
    <item>
      <title>String Calculation Evaluation</title>
      <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234793#M86120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great! Thanks, i got it working with some hints from that post. We can pick the formula we want dynamically in the script. I chose the 2nd formula in pick just for testing.&lt;/P&gt;&lt;P&gt;﻿&lt;/P&gt;&lt;P&gt;vartest:&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;id, field1, field2, calc&lt;/P&gt;&lt;P&gt;1 , 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 10&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1/field2&lt;/P&gt;&lt;P&gt;2 , 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 20&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1*field2&lt;/P&gt;&lt;P&gt;3 , 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 30&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1+field2&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let i=0;&lt;/P&gt;&lt;P&gt;let fxVarEvalN = fieldValue('calc',1);&lt;/P&gt;&lt;P&gt;for i = 2 to NoOfRows('vartest')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fxVarEvalN = fxVarEvalN &amp;amp; ',' &amp;amp; fieldValue('calc',$(i))&lt;/P&gt;&lt;P&gt;next i&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vartest2:&lt;/P&gt;&lt;P&gt;load id, pick(2, $(fxVarEvalN)) as pickedCalc;&lt;/P&gt;&lt;P&gt;load field1,field2,id&lt;/P&gt;&lt;P&gt;Resident vartest;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="qv example.bmp" class="jive-image" src="https://community.qlik.com/legacyfs/online/8639_qv+example.bmp" style="border-style: initial; border-color: initial;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Nov 2011 11:42:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/234793#M86120</guid>
      <dc:creator />
      <dc:date>2011-11-15T11:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: String Calculation Evaluation</title>
      <link>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/1642035#M447266</link>
      <description>&lt;P&gt;Thank you very much, it was really helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2019 11:30:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/String-Calculation-Evaluation/m-p/1642035#M447266</guid>
      <dc:creator>apsafos</dc:creator>
      <dc:date>2019-11-01T11:30:44Z</dc:date>
    </item>
  </channel>
</rss>

