<?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: Load Distinct keeping duplicate rows in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Load-Distinct-keeping-duplicate-rows/m-p/1608696#M736497</link>
    <description>&lt;P&gt;I think the issue is that your Temp Calendar is built on the date, and formatted to conform to 'YYYYMM'.&amp;nbsp; Give the code below a try for your TempCalendar table.&amp;nbsp; I'm sure it could be optimized, but it appears to create what you are looking for in the TempCalendar.&amp;nbsp; Since the TempCalendar is now at the correct level, the rest of your calendar should work as you are anticipating.&lt;/P&gt;&lt;P&gt;Let vMinDate = Num(AddYears(today(), -4));&lt;BR /&gt;Let vMaxDate = Num(Today());&lt;/P&gt;&lt;P&gt;TempCalendar:&lt;BR /&gt;Load Distinct&lt;BR /&gt;Date(MonthStart(Date($(vMinDate) + IterNo() - 1, 'YYYYMM')), 'YYYYMM') as [Account YearMonth]&lt;BR /&gt;AutoGenerate 1 while $(vMinDate) + IterNo() - 1 &amp;lt;= $(vMaxDate);&lt;/P&gt;&lt;P&gt;Good Luck,&lt;/P&gt;&lt;P&gt;Nate&lt;/P&gt;</description>
    <pubDate>Thu, 01 Aug 2019 20:10:15 GMT</pubDate>
    <dc:creator>hallquist_nate</dc:creator>
    <dc:date>2019-08-01T20:10:15Z</dc:date>
    <item>
      <title>Load Distinct keeping duplicate rows</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Distinct-keeping-duplicate-rows/m-p/1608680#M736496</link>
      <description>&lt;P&gt;I was writing script to build a few calendar tables that are linked to a few month fields instead of linked fields.&amp;nbsp; I would create the initial table based on a date (like a normal master calendar), but also calculate the corresponding month fields to go along with those.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My plan was then to load the distinct months from the temporary table to build out my other calendars, but instead of having one row per month it has one row per day, which means there are tons of duplicates.&lt;BR /&gt;&lt;BR /&gt;This makes sense from the perspective that there are no distinct loads in my temporary table, but that's not how I thought Load Distinct worked.&amp;nbsp; I created a workaround trimming the month fields and and starting the calendar from those fields instead, but thought this was pretty weird.&amp;nbsp; It would not work without the trim.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically my question is why my "AcctgCal" table has duplicate rows and how I could make it not have duplicate rows without that weird intermediate trim table.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DistinctScript.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/16426i5D5FD5324FAF5F10/image-size/large?v=v2&amp;amp;px=999" role="button" title="DistinctScript.PNG" alt="DistinctScript.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Distinct-keeping-duplicate-rows/m-p/1608680#M736496</guid>
      <dc:creator>Jagsfan82</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Load Distinct keeping duplicate rows</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Distinct-keeping-duplicate-rows/m-p/1608696#M736497</link>
      <description>&lt;P&gt;I think the issue is that your Temp Calendar is built on the date, and formatted to conform to 'YYYYMM'.&amp;nbsp; Give the code below a try for your TempCalendar table.&amp;nbsp; I'm sure it could be optimized, but it appears to create what you are looking for in the TempCalendar.&amp;nbsp; Since the TempCalendar is now at the correct level, the rest of your calendar should work as you are anticipating.&lt;/P&gt;&lt;P&gt;Let vMinDate = Num(AddYears(today(), -4));&lt;BR /&gt;Let vMaxDate = Num(Today());&lt;/P&gt;&lt;P&gt;TempCalendar:&lt;BR /&gt;Load Distinct&lt;BR /&gt;Date(MonthStart(Date($(vMinDate) + IterNo() - 1, 'YYYYMM')), 'YYYYMM') as [Account YearMonth]&lt;BR /&gt;AutoGenerate 1 while $(vMinDate) + IterNo() - 1 &amp;lt;= $(vMaxDate);&lt;/P&gt;&lt;P&gt;Good Luck,&lt;/P&gt;&lt;P&gt;Nate&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 20:10:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Distinct-keeping-duplicate-rows/m-p/1608696#M736497</guid>
      <dc:creator>hallquist_nate</dc:creator>
      <dc:date>2019-08-01T20:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Load Distinct keeping duplicate rows</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Distinct-keeping-duplicate-rows/m-p/1615662#M736498</link>
      <description>&lt;P&gt;Nicholas, did Nate's post do the trick for you?&amp;nbsp; If so, consider giving him credit by using the Accept as Solution button on that post, which will also let others know that worked.&lt;/P&gt;
&lt;P&gt;The only thing I have for you are some Design Blog posts where you might find something to help explain as well:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog" target="_blank"&gt;https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Search on the word calendar or date etc., and check out those hits, something there may have some further explanation or give you some other ideas as well.&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Brett&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 21:00:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Distinct-keeping-duplicate-rows/m-p/1615662#M736498</guid>
      <dc:creator>Brett_Bleess</dc:creator>
      <dc:date>2019-08-22T21:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Load Distinct keeping duplicate rows</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Distinct-keeping-duplicate-rows/m-p/1616192#M736499</link>
      <description>&lt;P&gt;Not sure why i didn't apply this to my code, but I did run a quick test and it did work, even when you change the temp table to&lt;/P&gt;&lt;P&gt;&lt;FONT size="1" color="#0000ff"&gt;&lt;STRONG&gt;Load&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT size="1" color="#0000ff"&gt;Distinct&lt;/FONT&gt;&lt;FONT size="1"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;Date&lt;/FONT&gt;&lt;FONT size="1"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT size="1" color="#808080"&gt;$(vMinDate)&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;FONT size="1"&gt; + &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;IterNo&lt;/FONT&gt;&lt;FONT size="1"&gt;() - 1) &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;as&lt;/FONT&gt; &lt;FONT size="1" color="#800000"&gt;TempDate&lt;/FONT&gt;&lt;FONT size="1"&gt;,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;Date&lt;/FONT&gt;&lt;FONT size="1"&gt;(&lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;MonthStart&lt;/FONT&gt;&lt;FONT size="1"&gt;(&lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;Date&lt;/FONT&gt;&lt;FONT size="1"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT size="1" color="#808080"&gt;$(vMinDate)&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;FONT size="1"&gt; + &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;IterNo&lt;/FONT&gt;&lt;FONT size="1"&gt;() - 1, 'YYYYMM')), 'YYYYMM') &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;as&lt;/FONT&gt; &lt;FONT size="1" color="#800000"&gt;[Account YearMonth]&lt;/FONT&gt;&lt;FONT size="1"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;AutoGenerate&lt;/FONT&gt;&lt;FONT size="1"&gt; 1 &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;while&lt;/FONT&gt; &lt;STRONG&gt;&lt;I&gt;&lt;FONT size="1" color="#808080"&gt;$(vMinDate)&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;FONT size="1"&gt; + &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;IterNo&lt;/FONT&gt;&lt;FONT size="1"&gt;() - 1 &amp;lt;= &lt;/FONT&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT size="1" color="#808080"&gt;$(vMaxDate)&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;FONT size="1"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;My accounting month calendar has distinct rows and I still have my temporary date field to link to another master calendar.&amp;nbsp; I'm assuming maybe what was happenign is Qlik was interpreting the below code as a dual, so the underlying numeric value was "distinct" even though the formatted values were duplicated?&amp;nbsp; I suppose that makes sense.&amp;nbsp; The below code also worked, with or without Distinct (Which makes sense)&lt;/P&gt;&lt;P&gt;&lt;FONT size="1" color="#0000ff"&gt;&lt;STRONG&gt;Load&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT size="1" color="#0000ff"&gt;Distinct&lt;/FONT&gt;&lt;FONT size="1"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;Date&lt;/FONT&gt;&lt;FONT size="1"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT size="1" color="#808080"&gt;$(vMinDate)&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;FONT size="1"&gt; + &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;IterNo&lt;/FONT&gt;&lt;FONT size="1"&gt;() - 1) &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;as&lt;/FONT&gt; &lt;FONT size="1" color="#800000"&gt;TempDate&lt;/FONT&gt;&lt;FONT size="1"&gt;,&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;Text&lt;/FONT&gt;&lt;FONT size="1"&gt;(&lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;Date&lt;/FONT&gt;&lt;FONT size="1"&gt;(&lt;/FONT&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT size="1" color="#808080"&gt;$(vMinDate)&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;FONT size="1"&gt; + &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;IterNo&lt;/FONT&gt;&lt;FONT size="1"&gt;() - 1,'YYYYMM')) &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;as&lt;/FONT&gt; &lt;FONT size="1" color="#800000"&gt;[Account YearMonth]&lt;/FONT&gt;&lt;FONT size="1"&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;AutoGenerate&lt;/FONT&gt;&lt;FONT size="1"&gt; 1 &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;while&lt;/FONT&gt; &lt;STRONG&gt;&lt;I&gt;&lt;FONT size="1" color="#808080"&gt;$(vMinDate)&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;FONT size="1"&gt; + &lt;/FONT&gt;&lt;FONT size="1" color="#0000ff"&gt;IterNo&lt;/FONT&gt;&lt;FONT size="1"&gt;() - 1 &amp;lt;= &lt;/FONT&gt;&lt;STRONG&gt;&lt;I&gt;&lt;FONT size="1" color="#808080"&gt;$(vMaxDate)&lt;/FONT&gt;&lt;/I&gt;&lt;/STRONG&gt;&lt;FONT size="1"&gt;; &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2019 19:25:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Distinct-keeping-duplicate-rows/m-p/1616192#M736499</guid>
      <dc:creator>Jagsfan82</dc:creator>
      <dc:date>2019-08-23T19:25:46Z</dc:date>
    </item>
  </channel>
</rss>

