<?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 Dynamic Arrays - Sets in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Dynamic-Arrays-Sets/m-p/301622#M111634</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;&amp;nbsp; I’m trying to annualize some data and I have this expression:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;= 12*(Sum(&amp;nbsp; {$1&amp;lt;Year = {2011}&amp;gt;}&amp;nbsp; Volume) / (vArchiveMonth))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;I’m summing up all of the volume up to “today” and dividing it by the current archive month (kind of like an accounting “book” date) and then multiplying by twelve.&amp;nbsp; The variable, vArchiveMonth is set at load time but can change at runtime.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;But sometimes people add data forward – into the next month beyond the archive month.&amp;nbsp; So I want to limit the numbers I sum() to only include data up to the archive month.&amp;nbsp; So I tried this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;= 12*(Sum(&amp;nbsp; {$1&amp;lt;Year = {2011}, NMonth &amp;lt;= {$(vArchiveMonth)}&amp;gt;}&amp;nbsp; Volume) / (vArchiveMonth))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;(NMonth is a numeric month field and I want it to be less-than-or-equal-to the archive month).&lt;SPAN style="color: #1f497d;"&gt;But that's no good because I need a "Set" for Month to equal.&amp;nbsp; -- I guess.&amp;nbsp; So I tried this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;= 12*(Sum(&amp;nbsp; {$1&amp;lt;Year = {2011}, NMonth = {$(vMos)}&amp;gt;}&amp;nbsp; Volume) / (vArchiveMonth))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;where vMos is a variable = 1,2,3,4,5,6,7&amp;nbsp; (just going up to July right now.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;And it works!&amp;nbsp; Hooray!&amp;nbsp; But it sucks!&amp;nbsp; Boo!&amp;nbsp; Way too much hard coded stuff is going on there. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;I'm sure I can figure out how to deal with the Year but how do I limit the number of months?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;One way is to be able to set and change the value of vMos at runtime.&amp;nbsp; And it should be relative to vArchiveMonth.&amp;nbsp; something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;for (int i = 1; i &amp;lt;= vArchiveMonth; i++) vMos += i;&amp;nbsp;&amp;nbsp;&amp;nbsp; // needs to be calulated at runtime because vArchiveMonth can change during.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;Or, I could try something completely different if anyone would like to suggest it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;thanks.&amp;nbsp; -Erik.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Sep 2011 21:30:43 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-09-29T21:30:43Z</dc:date>
    <item>
      <title>Dynamic Arrays - Sets</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-Arrays-Sets/m-p/301622#M111634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;&amp;nbsp; I’m trying to annualize some data and I have this expression:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;= 12*(Sum(&amp;nbsp; {$1&amp;lt;Year = {2011}&amp;gt;}&amp;nbsp; Volume) / (vArchiveMonth))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;I’m summing up all of the volume up to “today” and dividing it by the current archive month (kind of like an accounting “book” date) and then multiplying by twelve.&amp;nbsp; The variable, vArchiveMonth is set at load time but can change at runtime.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;But sometimes people add data forward – into the next month beyond the archive month.&amp;nbsp; So I want to limit the numbers I sum() to only include data up to the archive month.&amp;nbsp; So I tried this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;= 12*(Sum(&amp;nbsp; {$1&amp;lt;Year = {2011}, NMonth &amp;lt;= {$(vArchiveMonth)}&amp;gt;}&amp;nbsp; Volume) / (vArchiveMonth))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;(NMonth is a numeric month field and I want it to be less-than-or-equal-to the archive month).&lt;SPAN style="color: #1f497d;"&gt;But that's no good because I need a "Set" for Month to equal.&amp;nbsp; -- I guess.&amp;nbsp; So I tried this:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;= 12*(Sum(&amp;nbsp; {$1&amp;lt;Year = {2011}, NMonth = {$(vMos)}&amp;gt;}&amp;nbsp; Volume) / (vArchiveMonth))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;where vMos is a variable = 1,2,3,4,5,6,7&amp;nbsp; (just going up to July right now.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;And it works!&amp;nbsp; Hooray!&amp;nbsp; But it sucks!&amp;nbsp; Boo!&amp;nbsp; Way too much hard coded stuff is going on there. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;I'm sure I can figure out how to deal with the Year but how do I limit the number of months?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;One way is to be able to set and change the value of vMos at runtime.&amp;nbsp; And it should be relative to vArchiveMonth.&amp;nbsp; something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;for (int i = 1; i &amp;lt;= vArchiveMonth; i++) vMos += i;&amp;nbsp;&amp;nbsp;&amp;nbsp; // needs to be calulated at runtime because vArchiveMonth can change during.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;Or, I could try something completely different if anyone would like to suggest it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;thanks.&amp;nbsp; -Erik.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2011 21:30:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-Arrays-Sets/m-p/301622#M111634</guid>
      <dc:creator />
      <dc:date>2011-09-29T21:30:43Z</dc:date>
    </item>
    <item>
      <title>Dynamic Arrays - Sets</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-Arrays-Sets/m-p/301623#M111635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you are almost there, you could use search expression within the set expression to limit your month:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;= 12*(Sum(&amp;nbsp; {$1&amp;lt;Year = {2011}, NMonth = {"&amp;lt;=$(vArchiveMonth)"} &amp;gt;}&amp;nbsp; Volume) / (vArchiveMonth))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;Hope this helps and it works,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1f497d;"&gt;Stefan&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2011 23:31:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-Arrays-Sets/m-p/301623#M111635</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2011-09-29T23:31:54Z</dc:date>
    </item>
    <item>
      <title>Dynamic Arrays - Sets</title>
      <link>https://community.qlik.com/t5/QlikView/Dynamic-Arrays-Sets/m-p/301624#M111636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks.&amp;nbsp; I thought I had tried that but I must have had a typo in it somewhere.&amp;nbsp; Thanks again.&amp;nbsp; That works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Erik.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2011 03:10:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Dynamic-Arrays-Sets/m-p/301624#M111636</guid>
      <dc:creator />
      <dc:date>2011-09-30T03:10:25Z</dc:date>
    </item>
  </channel>
</rss>

