<?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 Inside field calculation? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315501#M708705</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have a table where one of the field contain claculation formula based on fields of the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&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;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to resident load this table in script and add new field which is based on calculation of "calc" field?&lt;/P&gt;&lt;P&gt;I've played with evaluate() function but the result is always null.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Nov 2011 13:34:59 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-11-11T13:34:59Z</dc:date>
    <item>
      <title>Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315501#M708705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have a table where one of the field contain claculation formula based on fields of the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&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;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to resident load this table in script and add new field which is based on calculation of "calc" field?&lt;/P&gt;&lt;P&gt;I've played with evaluate() function but the result is always null.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Nov 2011 13:34:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315501#M708705</guid>
      <dc:creator />
      <dc:date>2011-11-11T13:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315502#M708706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;see the attached file &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where i have took the expression in resident table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tab1:&lt;BR /&gt;load * inline [&lt;BR /&gt;id, field1, field2&lt;BR /&gt;1 , 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 10&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;2 , 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 20&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;3 , 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 30&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;4 , 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 30&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Load *,&lt;BR /&gt;if(rowno()=1,field1/field2,&lt;BR /&gt;if(rowno()=2,field1*field2,&lt;BR /&gt;if(rowno()=3,field1+field2,if(rowno()=4,field1-field2)))) as calc&lt;BR /&gt;resident tab1;&lt;/P&gt;&lt;P&gt;drop table tab1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Nov 2011 14:09:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315502#M708706</guid>
      <dc:creator>SunilChauhan</dc:creator>
      <dc:date>2011-11-11T14:09:01Z</dc:date>
    </item>
    <item>
      <title>Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315503#M708707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sunil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your answer but i'm looking for more general solution (if is possible) because the table in the first post is a sample table and the real data may contain many and different calculations and many fields included.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Nov 2011 14:12:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315503#M708707</guid>
      <dc:creator />
      <dc:date>2011-11-11T14:12:50Z</dc:date>
    </item>
    <item>
      <title>Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315504#M708708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Stefan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do you determine which fields are to be used in the calculation and what the calculations is?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your sample in the first post, what determines that field 1 is divided by field 2 as opposed to multiplied by field 2 or added to field 2 on the first record?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Nov 2011 15:31:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315504#M708708</guid>
      <dc:creator>john_duffy</dc:creator>
      <dc:date>2011-11-11T15:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315505#M708712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i don't determine nothinng. The "calc" field is a database field and the formula is stored in it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards!&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Nov 2011 15:39:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315505#M708712</guid>
      <dc:creator />
      <dc:date>2011-11-11T15:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315506#M708713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;that's an interesting question and I was attempted to say, yes you can do this using evaluate() function.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I remembered I played around with something similar few weeks ago (&lt;/SPAN&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/message/135222#135222"&gt;http://community.qlik.com/message/135222&lt;/A&gt;&lt;SPAN&gt;) and I just wanted to adapt that to your requirements. I couldn't make it to work again. Then I noticed I was now using QV10SR3 and I remembered using QV9 from time to time - and surprisingly, my linked demo script just works fine in QV9SR6.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I continued working on QV9, trying to integrate your requirements. To my surprise, I couldn't get some assumingly easy expressions like 'field1' to work either, it always return NULL, as you mentioned.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could access the data for already read in rows by using the peek() method, but this is not what you required. Hm, why this? Is the expression evaluated in a different context where the actual current input row fields are not accessible, like in a global context?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to investigate on this, but couldn't find any information in the help or the forum. Almost all examples are using quite easy expressions where they don't use current input row field values, most of the time examples like '6*8' or something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I then noticed that the problem might be similar to &lt;/SPAN&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/thread/15247"&gt;http://community.qlik.com/thread/15247&lt;/A&gt;&lt;SPAN&gt; and the statement Hector made. Not sure about this, I believe it has to do with QV's internal structure (latter issue probably with how and when expressions are (pre-)parsed and evaluated, which I believe will probably not be done on record base).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I played around with other functions, trying to evaluate() them on script load, something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table2:&lt;/P&gt;&lt;P&gt;LOAD id, field1, field2, calc,&lt;/P&gt;&lt;P&gt;if(IsNull(evaluate(calc))=-1,'no',evaluate(calc)) as Result;&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;&amp;nbsp; 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;4 , 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 40&amp;nbsp;&amp;nbsp;&amp;nbsp; , date(today())&lt;/P&gt;&lt;P&gt;5 , 5&amp;nbsp;&amp;nbsp;&amp;nbsp; , 50&amp;nbsp;&amp;nbsp; , "peek('field1',-1)*peek('field2',-1)"&lt;/P&gt;&lt;P&gt;7 , 7&amp;nbsp;&amp;nbsp; ,60&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , rowno() &lt;/P&gt;&lt;P&gt;8 , 8&amp;nbsp;&amp;nbsp;&amp;nbsp; , 70&amp;nbsp;&amp;nbsp; , rowno()*field1&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and I again noticed differences between QV 9 and 10, not only with the peek() function evaluation, but also with the rowno().&lt;/P&gt;&lt;P&gt;Finally, I was just about giving up, I remembered the "easy ones" using something like&lt;/P&gt;&lt;P&gt;evaluate('8*6')&lt;/P&gt;&lt;P&gt;so what about replacing the field values in the string to evaluate before evaluating?&lt;/P&gt;&lt;P&gt;And in fact, I got this to work for both QV9 and QV10:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Table2:&lt;/P&gt;&lt;P&gt;LOAD id, field1, field2, calc,calc2,&lt;/P&gt;&lt;P&gt; if(IsNull(evaluate(calc2))=-1,'no',evaluate(calc2)) as Result;&lt;/P&gt;&lt;P&gt; LOAD id, field1, field2, calc,&lt;/P&gt;&lt;P&gt; Replace(Replace(calc,'field1',text(field1)),'field2',text(field2)) as calc2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LOAD * INLINE [&lt;/P&gt;&lt;P&gt;&amp;nbsp; 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;Not sure if this meets your requirement, but I think I am at my wits' end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;another Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Nov 2011 14:22:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315506#M708713</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2011-11-12T14:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315507#M708714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What about using a variable with fields as parameters? Is that acceptable given your data model and possible values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;SET&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt; &lt;/SPAN&gt;&lt;SPAN class="s3"&gt;&lt;STRONG&gt;&lt;EM&gt;fxEval&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt; = Evaluate($1 &amp;amp; KeepChar($2, &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;'+-/*'&lt;/SPAN&gt;&lt;SPAN class="s2"&gt;) &amp;amp; $3);&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt; *, &lt;/SPAN&gt;&lt;SPAN class="s3"&gt;&lt;STRONG&gt;&lt;EM&gt;$(fxEval(field1, calc, field2))&lt;/EM&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;AS&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt; &lt;/SPAN&gt;calc2&lt;SPAN class="s2"&gt; &lt;/SPAN&gt;&lt;SPAN class="s1"&gt;&lt;STRONG&gt;INLINE&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN class="s2"&gt; &lt;/SPAN&gt;[&lt;BR /&gt;id, field1, field2, calc&lt;BR /&gt;1 , 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 10&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1/field2&lt;BR /&gt;2 , 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 20&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1*field2&lt;BR /&gt;3 , 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 30&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1+field2&lt;BR /&gt;]&lt;SPAN class="s2"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; font-size: 12px; color: #636363; font-family: Arial;"&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/people/mabaeyens" style="outline-style: none; padding-top: 1px; padding-bottom: 1px; padding-left: 17px; color: #007fc0; zoom: 1; background-position: no-repeat no-repeat;"&gt;Miguel Angel Baeyens&lt;/A&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; font-size: 12px; color: #636363; font-family: Arial;"&gt;BI Consultant&lt;/P&gt;&lt;P style="background-color: #ffffff; font-size: 12px; color: #636363; font-family: Arial;"&gt;&lt;A class="jive-link-external-small" href="http://www.grupocomex.com/" style="outline-style: none; color: #007fc0;"&gt;Comex Grupo Ibérica&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Nov 2011 19:17:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315507#M708714</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2011-11-13T19:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315508#M708715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Stefan i've ednded with the same situation &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Miguel using your solution actually show some results! But is there any way to adapt the variable to use randon number of fileds?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Nov 2011 20:10:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315508#M708715</guid>
      <dc:creator />
      <dc:date>2011-11-13T20:10:38Z</dc:date>
    </item>
    <item>
      <title>Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315509#M708716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the replace method will also work with more than two fields and if not every field is used in the calc string (the replace just won't have any effect for that field). So just extend the expression with more replace() functions up to maximum number of fields you need (well, I hope you are not using too many, and honestly I don't know if restrictions apply for too many functions embedded into other functions, just give it a try.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think replacing the field values is probably more flexible with regard to calc function structure, for example you will have not problems with such 'sqr(field1)' or 'field2 / field1' or 'field1 / (field2 + field1)'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope his helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Nov 2011 20:25:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315509#M708716</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2011-11-13T20:25:41Z</dc:date>
    </item>
    <item>
      <title>Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315510#M708717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why not store this in an Excel file and load the calc field?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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;- Ralf&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Nov 2011 20:47:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315510#M708717</guid>
      <dc:creator>rbecher</dc:creator>
      <dc:date>2011-11-13T20:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315511#M708718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've started with replacing method Stefan. Just to make it work but as far as i know my bosses they will offer the same qvw file to other of our clients and there the filed names are not totally the same. Thats why i'm looking for some solution that will save me some time in future &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ralf, is there any diff with loading from excel?!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Nov 2011 20:59:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315511#M708718</guid>
      <dc:creator />
      <dc:date>2011-11-13T20:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315512#M708719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed, Excel is calculating the formulas, but you migh know.. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/grin.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Nov 2011 21:22:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315512#M708719</guid>
      <dc:creator>rbecher</dc:creator>
      <dc:date>2011-11-13T21:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315513#M708720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Btw. if you want to abstract (map) your qvw fields from the customer fields w/o changing the qvw file you could provide an external script (qvs via include) with the mapping which will be customized on the client side.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Nov 2011 22:00:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315513#M708720</guid>
      <dc:creator>rbecher</dc:creator>
      <dc:date>2011-11-13T22:00:10Z</dc:date>
    </item>
    <item>
      <title>Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315514#M708721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ralf,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't known that something plain like 'field1+field2' will be a correct excel expression indicating the sum of columns titled field1 and field2 row based. But I surely am no Excel expert.&lt;/P&gt;&lt;P&gt;Could you elaborate on that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan, where does your data come from? Could your data source somehow handle the calculation itself? I believe some probably could do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Nov 2011 23:05:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315514#M708721</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2011-11-13T23:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315515#M708722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;At this stage I clearly have to ask what is the use case? As I've understand so far it is the abstraction from a client´s datamodel. The calculated fields is only one approach as a workaround, right?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 08:35:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315515#M708722</guid>
      <dc:creator>rbecher</dc:creator>
      <dc:date>2011-11-14T08:35:31Z</dc:date>
    </item>
    <item>
      <title>Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315516#M708723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; tab1:&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;Load * inline [&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;id, field1, field2, calc&lt;BR /&gt;1 , 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 10&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1/field2&lt;BR /&gt;2 , 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 20&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1*field2&lt;BR /&gt;3 , 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 30&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1+field2&lt;/CODE&gt;&lt;CODE class="jive-code"&gt;&lt;BR /&gt;];&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tab2:&lt;/P&gt;&lt;P&gt;Load * ,&lt;/P&gt;&lt;P&gt;if(Rowno()=1,field1/field2,if(Rowno()=2,field1*field2,if(Rowno()=1,field1+field2))) as Calc&lt;/P&gt;&lt;P&gt;residdent Tab1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop table Tab1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; tab1:&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;Load * inline [&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;id, field1, field2, calc&lt;BR /&gt;1 , 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 10&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1/field2&lt;BR /&gt;2 , 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 20&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1*field2&lt;BR /&gt;3 , 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 30&amp;nbsp;&amp;nbsp;&amp;nbsp; , field1+field2&lt;/CODE&gt;&lt;CODE class="jive-code"&gt;&lt;BR /&gt;];&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and in expression&lt;/P&gt;&lt;P&gt;if(Rowno()=1,field1/field2,if(Rowno()=2,field1*field2,if(Rowno()=1,field1+field2)))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 08:44:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315516#M708723</guid>
      <dc:creator>SunilChauhan</dc:creator>
      <dc:date>2011-11-14T08:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315517#M708724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ralf,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the idea is that all the fields are loaded from the db. including the calculation field. All folrmulas are stored in this field. And for particular rows this formula must override the regular calculation. And the formula and fields inside it may vary and they are user defined and may be changed by the end user of the application any time.&lt;/P&gt;&lt;P&gt;Some developer gave the user option to enter this formulas and now the customer want to have this in qlikview and some charts to be made.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 08:45:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315517#M708724</guid>
      <dc:creator />
      <dc:date>2011-11-14T08:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315518#M708725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If there is no simple way in QV I would prefer to do this in the script with dynamic SQL. But to show how this could work I would need more details: the data model and the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Ralf&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 08:56:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315518#M708725</guid>
      <dc:creator>rbecher</dc:creator>
      <dc:date>2011-11-14T08:56:25Z</dc:date>
    </item>
    <item>
      <title>Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315519#M708726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; did u see my post&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 10:30:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315519#M708726</guid>
      <dc:creator>SunilChauhan</dc:creator>
      <dc:date>2011-11-14T10:30:46Z</dc:date>
    </item>
    <item>
      <title>Inside field calculation?</title>
      <link>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315520#M708727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; This looks like working.&amp;nbsp; Functionality is correct, but it could be cleaner, I think.&amp;nbsp; Anyway, you can start from here and improve:&lt;/P&gt;&lt;P&gt;data:&lt;BR /&gt;LOAD *, rowno() as Row INLINE [&lt;BR /&gt; f1, f2, calc&lt;BR /&gt; 1, 5, "f1 + f2"&lt;BR /&gt; 4, 10, "f1 * f2"&lt;BR /&gt; 15, 5, "f1 / f2"];&lt;/P&gt;&lt;P&gt;Let R=peek('Row');&lt;/P&gt;&lt;P&gt;for r=1 to $(R)&lt;/P&gt;&lt;P&gt;LET E=peek('calc', $(r)-1,'data');&lt;/P&gt;&lt;P&gt; tab:&lt;BR /&gt; LOAD&lt;BR /&gt;&amp;nbsp; f1,&lt;BR /&gt;&amp;nbsp; f2,&lt;BR /&gt;&amp;nbsp; calc,&lt;BR /&gt;&amp;nbsp; evaluate($(E)) as Result&lt;BR /&gt; RESIDENT data&lt;BR /&gt; WHERE Row=$(r);&lt;/P&gt;&lt;P&gt;Next r&lt;/P&gt;&lt;P&gt;DROP TABLE data;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Nov 2011 21:19:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Inside-field-calculation/m-p/315520#M708727</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-11-14T21:19:16Z</dc:date>
    </item>
  </channel>
</rss>

