<?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: calculated SET variable based on fields in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419529#M1150308</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What a easy reply Gysbert.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 May 2013 11:12:17 GMT</pubDate>
    <dc:creator>sujeetsingh</dc:creator>
    <dc:date>2013-05-02T11:12:17Z</dc:date>
    <item>
      <title>calculated SET variable based on fields</title>
      <link>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419527#M1150306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a (beginner) question :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let's say I load 2 fields from a xls table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;[field A] as A,&lt;/P&gt;&lt;P&gt;[field B] as B&lt;/P&gt;&lt;P&gt;FROM xxxxx&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field A and B contains random numbers range 1 - 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I would like to have a variable vCal which calculates the difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SET vCAL = Sum($1 A) - Sum($1 B)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I'm a bit confused on where I need to place this SET variable. When I put it with the other standard SET variables at the beginning of the script it comes before the LOAD so it doesn't recognize the values&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot place a SET within the LOAD don't you? Or is it possible to do the following :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;field A as A,&lt;/P&gt;&lt;P&gt;field B as B&lt;/P&gt;&lt;P&gt;Cal = [Field A] - [Field B]&lt;/P&gt;&lt;P&gt;FROM xxxxx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 09:39:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419527#M1150306</guid>
      <dc:creator />
      <dc:date>2013-05-02T09:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: calculated SET variable based on fields</title>
      <link>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419528#M1150307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can do the calculations in the load by creating a new field that subtracts the two fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;LOAD&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;[field A] as A,&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;[field B] as B,&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;[field A] - [field B] as Cal&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;FROM xxxxx&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;The set statement &lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;SET vCAL = Sum($1 A) - Sum($1 B) creates a variable that contains an expression. That expression doesn't make sense though. Sum(A)-Sum(B) would make sense. You could such a variable in a chart objects. It would still be meaningless in the script though since it will miss the context that a chart would give it, i.e. dimensions to aggregate over. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 09:44:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419528#M1150307</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-05-02T09:44:57Z</dc:date>
    </item>
    <item>
      <title>Re: calculated SET variable based on fields</title>
      <link>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419529#M1150308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What a easy reply Gysbert.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 11:12:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419529#M1150308</guid>
      <dc:creator>sujeetsingh</dc:creator>
      <dc:date>2013-05-02T11:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: calculated SET variable based on fields</title>
      <link>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419530#M1150309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a similar problem to this, so i wonder if you can help.&lt;/P&gt;&lt;P&gt;I have the following table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Limits:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; max(Sales) as maxSale,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; min(Sales) as minSale&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;resident Sales;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I need to turn maxSale and minSale to variables to use in another Load statement which follows.&lt;/P&gt;&lt;P&gt;Tried it the following:&lt;/P&gt;&lt;P&gt;LET vMaxSaleAmount = peek(maxSale);&lt;/P&gt;&lt;P&gt;LET vMinSaleAmount = peek(minSale);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;Load $(vMinSaleAmount)-1+iterno() as Value&lt;/P&gt;&lt;P&gt;autogenerate 1 while iterno() &amp;lt;= $(vMaxSaleAmount)+1 - $(vMinSaleAmount);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wwhen reloading, there variable is not found in the 'Data' table. Can you help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 13:27:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419530#M1150309</guid>
      <dc:creator />
      <dc:date>2014-01-23T13:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: calculated SET variable based on fields</title>
      <link>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419531#M1150310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Zama&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need quotes in PEEK:&lt;/P&gt;&lt;P&gt;LET vMaxSaleAmount = peek('maxSale');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, it would be better to open a new thread instead of reusing seven months old discussion&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lukasz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jan 2014 13:48:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculated-SET-variable-based-on-fields/m-p/419531#M1150310</guid>
      <dc:creator />
      <dc:date>2014-01-23T13:48:43Z</dc:date>
    </item>
  </channel>
</rss>

