<?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: include variable in set expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533799#M199399</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A variable described this way behaves like a parameterised macro (or user defined function, if you prefer). The $1 refers to the first parameter, $2 to the second and so on. When the variables is evaluated, it uses the values passed in the brackets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So &lt;/P&gt;&lt;P&gt;=$(vGender(1))&lt;/P&gt;&lt;P&gt;is the same as &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;=sum({&amp;lt;gender_ID={1}&amp;gt;} %contact_counter)/sum({&amp;lt;gender_ID={1,2}&amp;gt;} total %contact_counter)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And&lt;/P&gt;&lt;P&gt;=$(vGender(2))&lt;/P&gt;&lt;P&gt;is the same as &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;=sum({&amp;lt;gender_ID={2}&amp;gt;} %contact_counter)/sum({&amp;lt;gender_ID={1,2}&amp;gt;} total %contact_counter)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I assumed that because you stated vGender that way in your post that you might want to use it that way. So there is no reason to use $(vGender(1,2)). (It would not work anyway as the comma is the separator between two parameters and if it did it would always return 1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Jul 2013 09:32:39 GMT</pubDate>
    <dc:creator>jonathandienst</dc:creator>
    <dc:date>2013-07-30T09:32:39Z</dc:date>
    <item>
      <title>include variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533795#M199395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi &lt;/P&gt;&lt;P&gt;i have defined this variable: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set vGender = sum({$&amp;lt;gender_ID={1,2}&amp;gt;} %contact_counter)/sum({$&amp;lt;gender_ID={1,2}&amp;gt;} total %contact_counter)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now i want to use the same variable in this expression, where I split the field name, but i do not want to select the different values with a list box or any other sheet object: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=RangeMax(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; (sum({$&amp;lt;gender_ID={1}&amp;gt;} %contact_counter)/sum({$&amp;lt;gender_ID={1,2}&amp;gt;} total %contact_counter))&lt;/P&gt;&lt;P&gt;&amp;nbsp; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; (sum({$&amp;lt;gender_ID={2}&amp;gt;} %contact_counter)/sum({$&amp;lt;gender_ID={1,2}&amp;gt;} total %contact_counter))&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please advice on this&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;felipe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13750954468579193" jivemacro_uid="_13750954468579193"&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2013 11:14:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533795#M199395</guid>
      <dc:creator>felcar2013</dc:creator>
      <dc:date>2013-07-29T11:14:32Z</dc:date>
    </item>
    <item>
      <title>Re: include variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533796#M199396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps I misunderstood your requirements, but the simple answer is you cant. You have defined vGender, but what you need is different. Why not simply use another variable?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2013 11:26:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533796#M199396</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2013-07-29T11:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: include variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533797#M199397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On reconsideration, if your define vGender like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set vGender = sum({&amp;lt;gender_ID={$1}&amp;gt;} %contact_counter)/sum({&amp;lt;gender_ID={1,2}&amp;gt;} total %contact_counter)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is now a parameterised macro and you would use it like this&lt;/P&gt;&lt;P&gt; =RangeMax($(vGender(1)), $(vGender(2)))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;The original form would be &lt;/P&gt;&lt;P&gt;&amp;nbsp; =$(vGender(1,2))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; If that does not work, you might need to include an extra = in the set statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;set vGender = =sum({&amp;lt;gender_ID={$1}&amp;gt;} %contact_counter)/sum({&amp;lt;gender_ID={1,2}&amp;gt;} total %contact_counter)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2013 11:33:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533797#M199397</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2013-07-29T11:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: include variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533798#M199398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks, first time i use this, it worked&lt;/P&gt;&lt;P&gt;i declared the vGender and then used as $(vGender(1)) and $(vGender(2)) for the rangemax()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did not use the =$(vGender(1,2)) . what did you mean with the original ?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i check this in the manual , but i do not understand how it is used. What does the " $1 " or "$2", etc. means?&lt;/P&gt;&lt;P&gt;is it the first set of values of my first field and $2 the second set of values of the next field included in the expression?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for vGender(1,2) you meant with original, that i have for that variable, a list of two parameters? do i need to use this in the script? &lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;felipe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2013 14:23:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533798#M199398</guid>
      <dc:creator>felcar2013</dc:creator>
      <dc:date>2013-07-29T14:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: include variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533799#M199399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A variable described this way behaves like a parameterised macro (or user defined function, if you prefer). The $1 refers to the first parameter, $2 to the second and so on. When the variables is evaluated, it uses the values passed in the brackets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So &lt;/P&gt;&lt;P&gt;=$(vGender(1))&lt;/P&gt;&lt;P&gt;is the same as &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;=sum({&amp;lt;gender_ID={1}&amp;gt;} %contact_counter)/sum({&amp;lt;gender_ID={1,2}&amp;gt;} total %contact_counter)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And&lt;/P&gt;&lt;P&gt;=$(vGender(2))&lt;/P&gt;&lt;P&gt;is the same as &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;=sum({&amp;lt;gender_ID={2}&amp;gt;} %contact_counter)/sum({&amp;lt;gender_ID={1,2}&amp;gt;} total %contact_counter)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I assumed that because you stated vGender that way in your post that you might want to use it that way. So there is no reason to use $(vGender(1,2)). (It would not work anyway as the comma is the separator between two parameters and if it did it would always return 1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jul 2013 09:32:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533799#M199399</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2013-07-30T09:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: include variable in set expression</title>
      <link>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533800#M199400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi thanks&lt;/P&gt;&lt;P&gt;it is very clear&lt;/P&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Jul 2013 15:15:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/include-variable-in-set-expression/m-p/533800#M199400</guid>
      <dc:creator>felcar2013</dc:creator>
      <dc:date>2013-07-30T15:15:49Z</dc:date>
    </item>
  </channel>
</rss>

