<?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: Alternative to load distinct in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306892#M113365</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the alternative and efficient way for getting distinct values of a field in a table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I have the following question. If Sales fact table has a 'Date' field having those dates on which there are sales data and if the 'Date' field in the [Master Calendar] table has every date from the minimum date to the maximum date, which 'Date' field will be used by the 'fieldvalue' to select the distinct dates?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 May 2011 23:15:04 GMT</pubDate>
    <dc:creator>nagaiank</dc:creator>
    <dc:date>2011-05-17T23:15:04Z</dc:date>
    <item>
      <title>Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306890#M113363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Everyone, I'm looking for an alternative to a "load distinct" type syntax used under the following scenario:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load A,B,C, Date&lt;/P&gt;&lt;P&gt;from fact;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load distinct Date&lt;/P&gt;&lt;P&gt;from fact;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that in this particular case an autogenerated master calendar approach would be better, however I'm just trying to find out a different way of loading only the distinct values in a particular field. Your help is very appreciated!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2011 22:41:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306890#M113363</guid>
      <dc:creator />
      <dc:date>2011-05-17T22:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306891#M113364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD date(fieldvalue('Date',iterno())) as Date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AUTOGENERATE 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHILE len(fieldvalue('Date',iterno()));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is VERY efficient.&amp;nbsp; It basically steps through QlikView's internal data to get your values without even referencing your original table.&amp;nbsp; So even if your original table has 100 million rows, if there are only 1000 Dates in it, this load will be over in a flash.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, it probably is still a good idea to do load distinct when you have a small table, if only because it is easier for newer developers to read and duplicate.&amp;nbsp; I don't, though.&amp;nbsp; I always use the above approach, regardless of table size, so that my code stays consistent.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2011 22:48:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306891#M113364</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-05-17T22:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306892#M113365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the alternative and efficient way for getting distinct values of a field in a table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However I have the following question. If Sales fact table has a 'Date' field having those dates on which there are sales data and if the 'Date' field in the [Master Calendar] table has every date from the minimum date to the maximum date, which 'Date' field will be used by the 'fieldvalue' to select the distinct dates?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2011 23:15:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306892#M113365</guid>
      <dc:creator>nagaiank</dc:creator>
      <dc:date>2011-05-17T23:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306893#M113366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A good question.&amp;nbsp; Fieldvalue() will use every value already loaded in ANY table since it doesn't reference a specific table.&amp;nbsp; One possible way around this in your example is to first load the sales fact table, then do the fieldvalue() load, and only THEN load your master calendar.&amp;nbsp; If that's impractical, another solution is to create a duplicate field, loading "Date" both as itself and as "TempDate", and then do the fieldvalue() load with "TempDate", and then drop "TempDate".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2011 23:22:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306893#M113366</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-05-17T23:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306894#M113367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 May 2011 23:24:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306894#M113367</guid>
      <dc:creator>nagaiank</dc:creator>
      <dc:date>2011-05-17T23:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306895#M113368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks John, indeed is very efficient and also is a clever way to avoid the load distinct. I'm going to use it from now on!!!. I played a little bit with the code, just for the fun of it and found QlikView behaving weird from version to version, here is the code snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let vFieldRows = FieldValueCount('Date');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD evaluate(fieldvalue('ID',iterno())) as DistinctDate&lt;/P&gt;&lt;P&gt;autogenerate(1)&lt;/P&gt;&lt;P&gt;while iterno() &amp;lt;= $(vFieldRows);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I tried it on version 9 SR6 x64 the code works fine and return the correct date number, however when I used version 10SR2 x64 it returns odd numbers, does anybody know why?? is it a bug???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2011 14:27:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306895#M113368</guid>
      <dc:creator />
      <dc:date>2011-05-18T14:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306896#M113369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think evaluate() works here.&amp;nbsp; Date() may be redundant, but I often have problems with QlikView recognizing what type of field something is after using fieldvalue(), so I pretty much always override it.&amp;nbsp; I never thought to use fieldvaluecount(), so that's a nice simplification - thanks!&amp;nbsp; However, using a variable seems unnecessary, and since we have a count, we don't need to iterate; we can just generate that number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD date(fieldvalue('Date',recno())) as Date&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AUTOGENERATE fieldvaluecount('Date');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That works fine for me in v10 SR2 x32.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2011 18:50:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306896#M113369</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-05-18T18:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306897#M113370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again John, you are right the loop is completely unnecesary, I missed that part, I don't seem to be thinking clearly lately. I used the evaluate function just to see what happend and it really surprised me because it does not seem to behave the same between version 9 and 10, that's akward.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2011 20:04:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306897#M113370</guid>
      <dc:creator />
      <dc:date>2011-05-19T20:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306898#M113371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been using a loop for this for years.&amp;nbsp; If anyone should be embarrassed for not spotting that we could get rid of it, it's me.&amp;nbsp; &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 May 2011 20:09:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306898#M113371</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2011-05-19T20:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306899#M113372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How is with 3 columns?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2013 20:22:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306899#M113372</guid>
      <dc:creator>farolito20</dc:creator>
      <dc:date>2013-01-03T20:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306900#M113373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;farolito20 wrote:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How is with 3 columns?&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you're asking how to load distinct values of three columns from a source?&amp;nbsp; So you're asking how to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;DistinctValues:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD DISTINCT A,B,C&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;FROM SOMEWHERE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd probably do it just as shown above.&amp;nbsp; The reason we could speed up finding distinct values of a single column is that QlikView was already tracking the distinct values internally.&amp;nbsp; But QlikView isn't tracking distinct &lt;EM&gt;combinations &lt;/EM&gt;of values internally, so far as I know.&amp;nbsp; Still, for the sake of argument, we can sort of do it with fieldvalue() with some setup.&amp;nbsp; I just expect this would perform worse instead of better, and it's certainly more complicated and more difficult to maintain.&amp;nbsp; So I recommend &lt;EM&gt;not &lt;/EM&gt;doing the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;// For amusement only&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Temp:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD A&amp;amp;':'&amp;amp;B&amp;amp;':'&amp;amp;C as ABC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;FROM SOMEWHERE&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;DistinctValues:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;subfield(ABC,':',1) as A&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,subfield(ABC,':',2) as B&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;,subfield(ABC,':',3) as C&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD text(fieldvalue('ABC',iterno())) as ABC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AUTOGENERATE fieldvaluecount('ABC')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;DROP TABLE Temp&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2013 20:36:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306900#M113373</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2013-01-03T20:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306901#M113374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;EM style="background-color: #ffffff; color: #737373; font-family: Arial;"&gt;not &lt;/EM&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;doing?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2013 21:41:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306901#M113374</guid>
      <dc:creator>farolito20</dc:creator>
      <dc:date>2013-01-03T21:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Alternative to load distinct</title>
      <link>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306902#M113375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right.&amp;nbsp; Use LOAD DISTINCT for three columns.&amp;nbsp; The fieldvalue() alternative "would perform worse instead of better, and it's certainly more complicated and more difficult to maintain."&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jan 2013 21:44:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Alternative-to-load-distinct/m-p/306902#M113375</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2013-01-03T21:44:01Z</dc:date>
    </item>
  </channel>
</rss>

