<?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: Loop through distinct count in the Script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loop-through-distinct-count-in-the-Script/m-p/667608#M668834</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;You'll need to use the Peek function in the script to assign the value to the variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try like this, after loading your initial table (let's say it's labeled T_Data):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T_Count:&lt;/P&gt;&lt;P&gt;Load count(distinct abc) as Cnt&lt;/P&gt;&lt;P&gt;resident T_Data;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let vLoop = peek('Cnt', 0, 'T_Count');&lt;/P&gt;&lt;P&gt;drop table T_Count;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i = $(vLoop) to 60&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Oct 2014 19:31:15 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-10-06T19:31:15Z</dc:date>
    <item>
      <title>Loop through distinct count in the Script</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-distinct-count-in-the-Script/m-p/667606#M668832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use &lt;STRONG&gt;For loop&lt;/STRONG&gt; using a variable which has been assigned a value using count function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Let vLoop = '=Count(DISTINCT abc)'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For i = $(vLoop) to 60&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Next i&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried with different combinations of Let and Set but none of them seems to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let vLoop = 'Count(DISTINCT abc)'&lt;/P&gt;&lt;P&gt;Let vLoop = Count(DISTINCT abc)&lt;/P&gt;&lt;P&gt;Set vLoop = '=Count(DISTINCT abc)'&lt;/P&gt;&lt;P&gt;Set vLoop = 'Count(DISTINCT abc)'&lt;/P&gt;&lt;P&gt;Set vLoop = Count(DISTINCT abc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas on what might I be doing wrong here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 18:53:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-distinct-count-in-the-Script/m-p/667606#M668832</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2014-10-06T18:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through distinct count in the Script</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-distinct-count-in-the-Script/m-p/667607#M668833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;is abc a field?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT&lt;/P&gt;&lt;P&gt;if yes try with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;t:&lt;/P&gt;&lt;P&gt;load * inline [&lt;/P&gt;&lt;P&gt;abc&lt;/P&gt;&lt;P&gt;a&lt;/P&gt;&lt;P&gt;b&lt;/P&gt;&lt;P&gt;c&lt;/P&gt;&lt;P&gt;c&lt;/P&gt;&lt;P&gt;d&lt;/P&gt;&lt;P&gt;d&lt;/P&gt;&lt;P&gt;e&lt;/P&gt;&lt;P&gt;e&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tmp: load count (distinct abc) as distinctabc resident t;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let v = peek('distinctabc');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i = v to 60&lt;/P&gt;&lt;P&gt;&amp;nbsp; trace $(i);&lt;/P&gt;&lt;P&gt;next;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 19:31:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-distinct-count-in-the-Script/m-p/667607#M668833</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-10-06T19:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through distinct count in the Script</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-distinct-count-in-the-Script/m-p/667608#M668834</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;You'll need to use the Peek function in the script to assign the value to the variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try like this, after loading your initial table (let's say it's labeled T_Data):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;T_Count:&lt;/P&gt;&lt;P&gt;Load count(distinct abc) as Cnt&lt;/P&gt;&lt;P&gt;resident T_Data;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let vLoop = peek('Cnt', 0, 'T_Count');&lt;/P&gt;&lt;P&gt;drop table T_Count;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for i = $(vLoop) to 60&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 19:31:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-distinct-count-in-the-Script/m-p/667608#M668834</guid>
      <dc:creator />
      <dc:date>2014-10-06T19:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through distinct count in the Script</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-through-distinct-count-in-the-Script/m-p/667609#M668835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes it was one of a field. Thanks your solution worked out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 19:56:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-through-distinct-count-in-the-Script/m-p/667609#M668835</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2014-10-06T19:56:04Z</dc:date>
    </item>
  </channel>
</rss>

