<?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: Looking for some help understanding parameters and variables in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Looking-for-some-help-understanding-parameters-and-variables/m-p/1817474#M1213123</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;as far as I can see, there is an error in your syntax of the ad-hoc variable. Your variable would evaluate to the following syntax:&lt;/P&gt;&lt;P&gt;sum({&amp;lt; MonthNumber = {"&amp;lt;=MonthNumber"} &amp;gt;} Sales)&lt;/P&gt;&lt;P&gt;which just gives "0" as result, since the ad-hoc variable isn't properly declared. If you use the following syntax:&lt;/P&gt;&lt;P&gt;=sum({&amp;lt;MonthNumber = {"&amp;lt;=$(=max(MonthNumber))" }&amp;gt;} Sales)&lt;/P&gt;&lt;P&gt;you will get the desired result.&lt;/P&gt;&lt;P&gt;To declare that variable in script, with parameters, you have to cut it in half, because QV doesn't allow a variable call within a variable declaration, so it needs to look like this:&lt;/P&gt;&lt;P&gt;let vSales = 'sum({&amp;lt;MonthNumber = {"&amp;lt;=$' &amp;amp; '(=max($1))" }&amp;gt;} Sales)';&lt;/P&gt;&lt;P&gt;And now, when you call the variable in a text box or a chart, it works as desired:&lt;/P&gt;&lt;P&gt;=$(vSales(MonthNumber))&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lenka_kruse_0-1624481333984.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/57450iF26EEC47DBA60A01/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lenka_kruse_0-1624481333984.png" alt="lenka_kruse_0-1624481333984.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 20:50:43 GMT</pubDate>
    <dc:creator>lenka_kruse</dc:creator>
    <dc:date>2021-06-23T20:50:43Z</dc:date>
    <item>
      <title>Looking for some help understanding parameters and variables</title>
      <link>https://community.qlik.com/t5/QlikView/Looking-for-some-help-understanding-parameters-and-variables/m-p/1817464#M1213121</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;In an effort to get a better understanding of variables, set analysis and $ expansion, I have a question:&lt;/P&gt;&lt;P&gt;In QlikView, I have this table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;MonthNumber&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Sales&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;125&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN&gt;I also have this variable:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;vSalesSoFar = sum({&amp;lt; MonthNumber = {"&amp;lt;=$1"} &amp;gt;} ROW_COUNT)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;In a TextBox, when I enter this expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=$(vSalesSoFar(4))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the result, 700, as expected. It is summing Month Numbers that are less than or equal to 4.&lt;/P&gt;&lt;P&gt;In the table, when I add this expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=$(vSalesSoFar(MonthNumber))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get 0.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":question_mark:"&gt;❓&lt;/span&gt;My first question is: Why doesn't the expression see the MonthNumber as the parameter?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To check this, I changed the expression to actually enter a number, in the table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=$(vSalesSoFar(4))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get 700 on each row, which makes sense to me.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Then I created this variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;vMonthPlus = $1 + 10&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I entered this expression in the table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=$(vMonthPlus(MonthNumber))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the correct output on each row:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;MonthNumber&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;vMonthPlus&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;My second question is: What is the difference between the two variables that the MonthNumber is recognized in one (vMonthPlus) but not the other (vSalesSoFar)?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 18:32:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Looking-for-some-help-understanding-parameters-and-variables/m-p/1817464#M1213121</guid>
      <dc:creator>treborscottnam</dc:creator>
      <dc:date>2021-06-23T18:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for some help understanding parameters and variables</title>
      <link>https://community.qlik.com/t5/QlikView/Looking-for-some-help-understanding-parameters-and-variables/m-p/1817474#M1213123</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;as far as I can see, there is an error in your syntax of the ad-hoc variable. Your variable would evaluate to the following syntax:&lt;/P&gt;&lt;P&gt;sum({&amp;lt; MonthNumber = {"&amp;lt;=MonthNumber"} &amp;gt;} Sales)&lt;/P&gt;&lt;P&gt;which just gives "0" as result, since the ad-hoc variable isn't properly declared. If you use the following syntax:&lt;/P&gt;&lt;P&gt;=sum({&amp;lt;MonthNumber = {"&amp;lt;=$(=max(MonthNumber))" }&amp;gt;} Sales)&lt;/P&gt;&lt;P&gt;you will get the desired result.&lt;/P&gt;&lt;P&gt;To declare that variable in script, with parameters, you have to cut it in half, because QV doesn't allow a variable call within a variable declaration, so it needs to look like this:&lt;/P&gt;&lt;P&gt;let vSales = 'sum({&amp;lt;MonthNumber = {"&amp;lt;=$' &amp;amp; '(=max($1))" }&amp;gt;} Sales)';&lt;/P&gt;&lt;P&gt;And now, when you call the variable in a text box or a chart, it works as desired:&lt;/P&gt;&lt;P&gt;=$(vSales(MonthNumber))&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lenka_kruse_0-1624481333984.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/57450iF26EEC47DBA60A01/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lenka_kruse_0-1624481333984.png" alt="lenka_kruse_0-1624481333984.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 20:50:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Looking-for-some-help-understanding-parameters-and-variables/m-p/1817474#M1213123</guid>
      <dc:creator>lenka_kruse</dc:creator>
      <dc:date>2021-06-23T20:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for some help understanding parameters and variables</title>
      <link>https://community.qlik.com/t5/QlikView/Looking-for-some-help-understanding-parameters-and-variables/m-p/1817499#M1213129</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@&lt;A href="https://www.myccpay.bid/" target="_self"&gt;myccpay&lt;/A&gt; wrote:&lt;BR /&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;In an effort to get a better understanding of variables, set analysis and $ expansion, I have a question:&lt;/P&gt;&lt;P&gt;In QlikView, I have this table:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;MonthNumber&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Sales&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;125&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;175&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;SPAN&gt;I also have this variable:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;vSalesSoFar = sum({&amp;lt; MonthNumber = {"&amp;lt;=$1"} &amp;gt;} ROW_COUNT)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;In a TextBox, when I enter this expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=$(vSalesSoFar(4))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the result, 700, as expected. It is summing Month Numbers that are less than or equal to 4.&lt;/P&gt;&lt;P&gt;In the table, when I add this expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=$(vSalesSoFar(MonthNumber))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get 0.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":question_mark:"&gt;❓&lt;/span&gt;My first question is: Why doesn't the expression see the MonthNumber as the parameter?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To check this, I changed the expression to actually enter a number, in the table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=$(vSalesSoFar(4))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get 700 on each row, which makes sense to me.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Then I created this variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;vMonthPlus = $1 + 10&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I entered this expression in the table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=$(vMonthPlus(MonthNumber))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the correct output on each row:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;MonthNumber&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;vMonthPlus&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;My second question is: What is the difference between the two variables that the MonthNumber is recognized in one (vMonthPlus) but not the other (vSalesSoFar)?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;Parameters are the things defined by functions as input, arguments are the things passed as parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void foo(int bar) { ... }

foo(baz);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In this example,&amp;nbsp;bar&amp;nbsp;is a parameter for&amp;nbsp;foo.&amp;nbsp;baz&amp;nbsp;is an argument passed to&amp;nbsp;foo.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jun 2021 04:29:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Looking-for-some-help-understanding-parameters-and-variables/m-p/1817499#M1213129</guid>
      <dc:creator>Amos857</dc:creator>
      <dc:date>2021-06-25T04:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for some help understanding parameters and variables</title>
      <link>https://community.qlik.com/t5/QlikView/Looking-for-some-help-understanding-parameters-and-variables/m-p/1817688#M1213148</link>
      <description>&lt;P&gt;Hi Lenka_kruse,&lt;/P&gt;&lt;P&gt;I really appreciate your response. Besides getting my expression to work, it was very helpful and caused me to go back and try to get a better understanding of it.&lt;/P&gt;&lt;P&gt;Is the MAX function needed only when using this expression in a table? I tried experminting with the MAX function in and out of the variable and it also seemed to work when MAX was removed. However, if no MonthNumber was selected, it returned 0. I needed to make a MonthNumber number selection to have it return a number.&lt;/P&gt;&lt;P&gt;What is the reason for that?&lt;/P&gt;&lt;P&gt;Thank you so much for the help!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 16:38:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Looking-for-some-help-understanding-parameters-and-variables/m-p/1817688#M1213148</guid>
      <dc:creator>treborscottnam</dc:creator>
      <dc:date>2021-06-24T16:38:34Z</dc:date>
    </item>
  </channel>
</rss>

