<?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: Load static value for variable in script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984105#M958808</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Temp:&lt;/P&gt;&lt;P&gt;LOAD sum(ItemVal) as SumOfItemVal FROM ...MyTable...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vItemValTotal = peek('&lt;SPAN style="font-size: 13.3333px;"&gt;SumOfItemVal');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Drop Table Temp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Oct 2015 18:41:33 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2015-10-28T18:41:33Z</dc:date>
    <item>
      <title>Load static value for variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984104#M958807</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 table with a ItemVal field, which is a numerical field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a static value for the total value of the ItemVal field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought this would work, but it doesn't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vItemValTotal = sum(ItemVal);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know I can enclose in single apostrophe and use it with $ expansion, but I don't want to do that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 18:38:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984104#M958807</guid>
      <dc:creator>mazacini</dc:creator>
      <dc:date>2015-10-28T18:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Load static value for variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984105#M958808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Temp:&lt;/P&gt;&lt;P&gt;LOAD sum(ItemVal) as SumOfItemVal FROM ...MyTable...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vItemValTotal = peek('&lt;SPAN style="font-size: 13.3333px;"&gt;SumOfItemVal');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Drop Table Temp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 18:41:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984105#M958808</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-10-28T18:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Load static value for variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984106#M958809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Gysbert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you mind if I ask you some questions?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my LET statement in isolation does not actually perform the SUM calculation?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does the LET statement in your example have to follow immediately on from the LOAD?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've only ever used PEEK in the context of adding a field to a table based on data already in that table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But from your solution, it operates across the model as a whole also? I assume it is significant that the "SumOfItemVal' field contains only a single value?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 18:58:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984106#M958809</guid>
      <dc:creator>mazacini</dc:creator>
      <dc:date>2015-10-28T18:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Load static value for variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984107#M958810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;BTW, I should point out that your solution worked perfectly!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 19:05:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984107#M958810</guid>
      <dc:creator>mazacini</dc:creator>
      <dc:date>2015-10-28T19:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Load static value for variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984108#M958811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px; background-color: #f2f2f2;"&gt;So my LET statement in isolation does not actually perform the SUM calculation?&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;That's correct. The Sum can only be calculated in a load statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px; background-color: #f2f2f2;"&gt;Does the LET statement in your example have to follow immediately on from the LOAD?&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;No, anywhere after the Temp table with the sum is created and before that table is dropped.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px; background-color: #f2f2f2;"&gt;But from your solution, it operates across the model as a whole also? I assume it is significant that the "SumOfItemVal' field contains only a single value?&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Without passig an additional parameter peek will use -1 to retrieve a value from the last row of the source table. If the field exists in more then one table then you need to specify the name of the source table too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 19:06:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984108#M958811</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-10-28T19:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Load static value for variable in script</title>
      <link>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984109#M958812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's great, Gysbert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2015 19:09:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-static-value-for-variable-in-script/m-p/984109#M958812</guid>
      <dc:creator>mazacini</dc:creator>
      <dc:date>2015-10-28T19:09:39Z</dc:date>
    </item>
  </channel>
</rss>

