<?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 Problem with assigning result of an expression to a variable in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-with-assigning-result-of-an-expression-to-a-variable/m-p/304734#M1193100</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much! It never occured to me that I'm trying something that cannot work...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Jun 2011 10:05:20 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-06-22T10:05:20Z</dc:date>
    <item>
      <title>Problem with assigning result of an expression to a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-assigning-result-of-an-expression-to-a-variable/m-p/304732#M1193097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The following expression works fine when I use it in a QlikView control:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;=Sum({$&amp;lt;fact_ReconciliationStockValueSAP.sap_stock_value_date = {'$(=Date(Min(fact_ReconciliationTransactions.transaction_date) - 1))'}&amp;gt;} fact_ReconciliationStockValueSAP.stock_value)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt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;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;LET vTest &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;= Sum({$&amp;lt;fact_ReconciliationStockValueSAP.sap_stock_value_date = {'$(=Date(Min(fact_ReconciliationTransactions.transaction_date) - 1))'}&amp;gt;} fact_ReconciliationStockValueSAP.stock_value)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I have also tried the $-expansion but did not manage to get the expression to function. I always get the following error:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;﻿&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Aggregation expressions not allowed in GROUP BY clause&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;LET vTest = Sum({$&amp;lt;fact_ReconciliationStockValueSAP.sap_stock_value_date = {&lt;STRONG&gt;'&lt;SPAN style="color: #ff0000;"&gt;(internal error)&lt;/SPAN&gt;'&lt;/STRONG&gt;}&amp;gt;} fact_ReconciliationStockValueSAP.stock_value)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;﻿&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;﻿What am I doing wrong?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;﻿&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;﻿Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;﻿Thomas&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jun 2011 05:49:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-assigning-result-of-an-expression-to-a-variable/m-p/304732#M1193097</guid>
      <dc:creator />
      <dc:date>2011-06-21T05:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with assigning result of an expression to a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-assigning-result-of-an-expression-to-a-variable/m-p/304733#M1193098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;At issue is that the scripting language is deceptively similar to the UI expressions language - but not the same!   The two differences that are tripping you up are&lt;/P&gt;&lt;P&gt;1. set expressions are not supported in scripts&lt;/P&gt;&lt;P&gt;2. aggregation functions are only for evaluation in the context of LOAD or SELECT statements.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;So, if you really want to get an aggregated value into a variable, you'd need to construct a LOAD statement that calculates the aggregation you want and has a WHERE clause to do the filtering that's equivalent to your set expression, and that results in a single record containing that value &lt;/P&gt;&lt;P&gt;(i.e. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    MyAggr: &lt;/P&gt;&lt;P&gt;    LOAD SUM(fact_ReconciliationStockValueSAP.stock_value) &lt;/P&gt;&lt;P&gt;    WHERE ;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;) ;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;and then use peek() to get the value into your variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jun 2011 06:06:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-assigning-result-of-an-expression-to-a-variable/m-p/304733#M1193098</guid>
      <dc:creator>gussfish</dc:creator>
      <dc:date>2011-06-21T06:06:49Z</dc:date>
    </item>
    <item>
      <title>Problem with assigning result of an expression to a variable</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-assigning-result-of-an-expression-to-a-variable/m-p/304734#M1193100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much! It never occured to me that I'm trying something that cannot work...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2011 10:05:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-assigning-result-of-an-expression-to-a-variable/m-p/304734#M1193100</guid>
      <dc:creator />
      <dc:date>2011-06-22T10:05:20Z</dc:date>
    </item>
  </channel>
</rss>

