<?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 causing duplicate records which i want to erase in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929472#M76525</link>
    <description>&lt;P&gt;i think your problem is here:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;min([CUSTOMER ID]),&lt;BR /&gt;min([Amount]),&lt;BR /&gt;min([FLAG NEW CUSTOMER]),&lt;BR /&gt;[RECEIPT ID],&lt;BR /&gt;[Date Customer]&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Resident TEMP&lt;BR /&gt;Group By&lt;BR /&gt;[RECEIPT ID],&lt;BR /&gt;[Date Customer]&lt;/P&gt;
&lt;P&gt;you are aggregating across all customers which will not yield any useful information.&amp;nbsp; if you feel you really need to use the script you have, pls post it and add sample data and outcome so others can see what is causing the problem otherwise everyone will just be guessing&lt;/P&gt;</description>
    <pubDate>Wed, 11 May 2022 19:50:20 GMT</pubDate>
    <dc:creator>edwin</dc:creator>
    <dc:date>2022-05-11T19:50:20Z</dc:date>
    <item>
      <title>loop causing duplicate records which i want to erase</title>
      <link>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929357#M76515</link>
      <description>&lt;P&gt;hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i have the following script&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;FOR i = 1 TO 4&lt;/P&gt;
&lt;P&gt;LET vL.BeginingDate = MonthStart(Addmonths(today(),-(6+'$(i)')));&lt;BR /&gt;LET vL.EndDate = MonthEnd(Addmonths(today(),-'$(i)'));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Trace DATE DEBUT ###### $(vL.BeginingDate) #########;&lt;BR /&gt;Trace DATE FIN ###### $(vL.EndDate) #########;&lt;/P&gt;
&lt;P&gt;TEMP:&lt;BR /&gt;Load &lt;BR /&gt;[CUSTOMER ID],&lt;BR /&gt;[Amount],&lt;BR /&gt;[Min Date Customer],&lt;BR /&gt;'$(i)' AS [FLAG NEW CUSTOMER],&lt;BR /&gt;[ORDER ID]&lt;/P&gt;
&lt;P&gt;WHERE [Date Customer] &amp;gt;= '$(vL.DatePeriodDebut)' AND [Date Customer] &amp;lt;= '$(vL.DatePeriodFin)';&lt;/P&gt;
&lt;P&gt;//Attempt to reduce the duplicate records because of the flag field "[FLAG NEW CUSTOMER]".&lt;BR /&gt;So i only want to get the firs record of this perticular field.&lt;BR /&gt;Because i goes from 1 to 4 i only want to get the record where a customer has ordered a particular item.&lt;/P&gt;
&lt;P&gt;basically for the&amp;nbsp;FLAG NEW CUSTOMER] it will get n values from 1 to n if the order id is in the date period&lt;BR /&gt;So a same order id can be there for each loop which i don't want&lt;/P&gt;
&lt;P&gt;to get the firs value of [FLAG NEW CUSTOMER] field i tried&lt;/P&gt;
&lt;P&gt;Option 1&lt;BR /&gt;Load Distinct&lt;BR /&gt;min([CUSTOMER ID]),&lt;BR /&gt;min([Amount]),&lt;BR /&gt;min([FLAG NEW CUSTOMER]),&lt;BR /&gt;[RECEIPT ID],&lt;BR /&gt;[Date Customer]&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Resident TEMP&lt;BR /&gt;Group By&lt;BR /&gt;[RECEIPT ID],&lt;BR /&gt;[Date Customer];&lt;BR /&gt;&lt;BR /&gt;I got for the field FLAG NEW CUSTOMER] all values at 1 which is impossible.&lt;BR /&gt;I used minstring it didn't work.&lt;/P&gt;
&lt;P&gt;anyone can help ?&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 16:05:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929357#M76515</guid>
      <dc:creator>random_user_3869</dc:creator>
      <dc:date>2022-05-11T16:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: loop causing duplicate records which i want to erase</title>
      <link>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929421#M76519</link>
      <description>&lt;P&gt;it sounds like you wanted to the the 6-month window where the customer ordered a product the first time.&amp;nbsp; is that the requirement?&amp;nbsp; maybe there is a way to go about this without using loops and just using table operations.&amp;nbsp; if you have a huge data set the loop might be slow.&lt;/P&gt;
&lt;P&gt;if you can provide sample data and the expected result it would be helpful.&lt;/P&gt;
&lt;P&gt;if you still want to use your code, i would suggest changing this part :&amp;nbsp;&lt;SPAN&gt;'$(i)' AS [FLAG NEW CUSTOMER],&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;to&amp;nbsp;$(i) AS [FLAG NEW CUSTOMER],&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;it then becomes numeric and you should be able to use min()&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 18:19:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929421#M76519</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2022-05-11T18:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: loop causing duplicate records which i want to erase</title>
      <link>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929430#M76520</link>
      <description>&lt;P&gt;I use a loop because afterward i need to calculate the cumulative period from previous month n to other periode as well.&lt;/P&gt;
&lt;P&gt;The flag field allow me to:&lt;/P&gt;
&lt;P&gt;if it equal 1 then i now that it's the rolling 6 month started from previous month&lt;/P&gt;
&lt;P&gt;it it equal 2 it is previous month minus 2 and so on&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you for your input.&lt;/P&gt;
&lt;P&gt;i will try and let you know !&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 18:39:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929430#M76520</guid>
      <dc:creator>random_user_3869</dc:creator>
      <dc:date>2022-05-11T18:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: loop causing duplicate records which i want to erase</title>
      <link>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929434#M76521</link>
      <description>&lt;P&gt;sure try but just suggesting that table operations are a lot faster than loops&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 18:48:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929434#M76521</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2022-05-11T18:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: loop causing duplicate records which i want to erase</title>
      <link>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929451#M76524</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lessassy_3869_0-1652296623288.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/79214i6109F72E527AA798/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lessassy_3869_0-1652296623288.png" alt="lessassy_3869_0-1652296623288.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here are the mltiple records for a single receipt id.&lt;/P&gt;
&lt;P&gt;Here i only want the first record.&lt;/P&gt;
&lt;P&gt;Even with your advice when i apply min i get one for every single value which is impossible&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 19:18:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929451#M76524</guid>
      <dc:creator>random_user_3869</dc:creator>
      <dc:date>2022-05-11T19:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: loop causing duplicate records which i want to erase</title>
      <link>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929472#M76525</link>
      <description>&lt;P&gt;i think your problem is here:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;min([CUSTOMER ID]),&lt;BR /&gt;min([Amount]),&lt;BR /&gt;min([FLAG NEW CUSTOMER]),&lt;BR /&gt;[RECEIPT ID],&lt;BR /&gt;[Date Customer]&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Resident TEMP&lt;BR /&gt;Group By&lt;BR /&gt;[RECEIPT ID],&lt;BR /&gt;[Date Customer]&lt;/P&gt;
&lt;P&gt;you are aggregating across all customers which will not yield any useful information.&amp;nbsp; if you feel you really need to use the script you have, pls post it and add sample data and outcome so others can see what is causing the problem otherwise everyone will just be guessing&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 19:50:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929472#M76525</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2022-05-11T19:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: loop causing duplicate records which i want to erase</title>
      <link>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929494#M76529</link>
      <description>&lt;P&gt;FOR i = 1 TO 4&lt;/P&gt;
&lt;P&gt;LET vL.BeginingDate = MonthStart(Addmonths(today(),-(6+'$(i)')));&lt;BR /&gt;LET vL.EndDate = MonthEnd(Addmonths(today(),-'$(i)'));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are loading data for overlapping periods here!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If today is 12May2022&lt;/P&gt;
&lt;P&gt;Loop 1&lt;/P&gt;
&lt;P&gt;Beginning date = 1dec2021&lt;/P&gt;
&lt;P&gt;End date= 30apr2022&lt;/P&gt;
&lt;P&gt;Loop2&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Beginning date = 1jan2021&lt;/P&gt;
&lt;P&gt;End date= 31march2022&lt;/P&gt;
&lt;P&gt;??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need to duplicate your data for calculating rolling months&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Refer this post&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.qlik.com/t5/QlikView-Documents/Calculating-rolling-n-period-totals-averages-or-other/ta-p/1483033" target="_blank"&gt;https://community.qlik.com/t5/QlikView-Documents/Calculating-rolling-n-period-totals-averages-or-other/ta-p/1483033&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;There is plenty of more content on rolling sums, but you need not duplicate the data for this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2022 20:34:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/loop-causing-duplicate-records-which-i-want-to-erase/m-p/1929494#M76529</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2022-05-11T20:34:23Z</dc:date>
    </item>
  </channel>
</rss>

