<?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 Loop Script help in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079946#M637265</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am quite new in development in QlikView scripting and I would like to ask for help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My original data consist of 3 columns: Date, Part_old and Part_new. When there is just one change there is no problem for me to write script. Problem is when, like you see in example a part&amp;nbsp; 'aaaa' is replaced&amp;nbsp; by 'bbbb' on January 1st and afterwards the part 'bbbb' to 'eeee'. Below you can see the original data structure and&amp;nbsp; the desired new layout. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought about do while statement, but I am not able to declare variable which will take the value from column C, check the whole column B to find whether there is more replacements of part and write it in a way I described above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Example.GIF" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/121002_Example.GIF" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Thanks for help&lt;/P&gt;&lt;P&gt;Michal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Apr 2016 06:04:10 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-04-08T06:04:10Z</dc:date>
    <item>
      <title>Loop Script help</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079946#M637265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am quite new in development in QlikView scripting and I would like to ask for help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My original data consist of 3 columns: Date, Part_old and Part_new. When there is just one change there is no problem for me to write script. Problem is when, like you see in example a part&amp;nbsp; 'aaaa' is replaced&amp;nbsp; by 'bbbb' on January 1st and afterwards the part 'bbbb' to 'eeee'. Below you can see the original data structure and&amp;nbsp; the desired new layout. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thought about do while statement, but I am not able to declare variable which will take the value from column C, check the whole column B to find whether there is more replacements of part and write it in a way I described above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Example.GIF" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/121002_Example.GIF" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Thanks for help&lt;/P&gt;&lt;P&gt;Michal&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2016 06:04:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079946#M637265</guid>
      <dc:creator />
      <dc:date>2016-04-08T06:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Script help</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079947#M637266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't really understand what you are trying to do here. Can you may be elaborate a little more?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2016 16:11:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079947#M637266</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-04-08T16:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Script help</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079948#M637267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shouldn't the third line / 'Partold_original' value&amp;nbsp; be 'cccc'?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2016 16:19:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079948#M637267</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-04-08T16:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Script help</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079949#M637268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes &lt;A href="https://community.qlik.com/qlik-users/15823"&gt;swuehl&lt;/A&gt;‌, you are right. It is 'cccc'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The idea is that original table is sorted by date in ascending order (older to younger) when Part_old was subsituted by Part_new, but there can&amp;nbsp; be &lt;STRONG&gt;1 to n&lt;/STRONG&gt; substitutes.&amp;nbsp; I would like to see those substitutes line by line. It means that part_new can be in another line shown like part_old substituted by another part. The aim is to create script to check it and organize it in a way shown above. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Column D will just show the first original part and doesn't take into consideration no of substitutes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2016 16:58:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079949#M637268</guid>
      <dc:creator />
      <dc:date>2016-04-08T16:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Script help</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079950#M637269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is another idea. Not really sure if this is applicable to your setting, let's see:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14601567468888796 jive_text_macro" jivemacro_uid="_14601567468888796"&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hierarchy:&lt;/P&gt;
&lt;P&gt;Hierarchy (Part_new,Part_old, NodeName,ParentName,NodeName,Path,'/',Depth)&lt;/P&gt;
&lt;P&gt;LOAD *,&amp;nbsp; Part_new as NodeName, RowNo() as RowID;&lt;/P&gt;
&lt;P&gt;LOAD Date, RecID, If(IterNo()=2,Null(),Part_old) as Part_old, If (IterNo()=2,Part_old,Part_new) as Part_new&lt;/P&gt;
&lt;P&gt;While iterno() &amp;lt;= Num;&lt;/P&gt;
&lt;P&gt;LOAD *, Recno() as RecID, If(not Exists(Part_new,Part_old),2,1) as Num INLINE [&lt;/P&gt;
&lt;P&gt;Date, Part_old, Part_new&lt;/P&gt;
&lt;P&gt;01.01.2016,aaaa,bbbb&lt;/P&gt;
&lt;P&gt;01.01.2016,cccc,ddddd&lt;/P&gt;
&lt;P&gt;03.02.2016,bbbb,eeee&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;RESULT:&lt;/P&gt;
&lt;P&gt;LOAD *, Subfield(Path,'/',1) as Part_old_orig&lt;/P&gt;
&lt;P&gt;Resident Hierarchy&lt;/P&gt;
&lt;P&gt;WHERE Len(trim(Part_old));&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;DROP TABLE Hierarchy;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE bgcolor="#ffffff" border="1" cellpadding="2" cellspacing="0" style="font-size: 9pt;"&gt;&lt;TBODY&gt;&lt;TR bgcolor="#f5f5f5"&gt;&lt;TH nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/TH&gt;&lt;TH nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;&lt;STRONG&gt;Part_old&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/TH&gt;&lt;TH nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;&lt;STRONG&gt;Part_new&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/TH&gt;&lt;TH nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;&lt;STRONG&gt;Part_old_orig&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/TH&gt;&lt;TH nowrap="nowrap"&gt;&lt;SPAN style="color: #363636;"&gt;&lt;STRONG&gt;Path&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR bgcolor="#ffffff"&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;01.01.2016&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;aaaa&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;bbbb&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;aaaa&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;aaaa/bbbb&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR bgcolor="#ffffff"&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;03.02.2016&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;bbbb&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;eeee&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;aaaa&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;aaaa/bbbb/eeee&lt;/SPAN&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;TR bgcolor="#ffffff"&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;01.01.2016&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;cccc&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;ddddd&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;cccc&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD bgcolor="#ffffff"&gt;&lt;SPAN style="color: #363636;"&gt;cccc/ddddd&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Apr 2016 23:07:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079950#M637269</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-04-08T23:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Script help</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079951#M637270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great!! Thank you very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just&amp;nbsp; noticed one problem. I try to apply order by statement but without success because sometimes the path is going form older date to younger, sometimes vice versa, any suggestions to which line apply the condition??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Apr 2016 12:06:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079951#M637270</guid>
      <dc:creator />
      <dc:date>2016-04-11T12:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Script help</title>
      <link>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079952#M637271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could you upload a small sample of your input data and your current script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Apr 2016 23:19:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loop-Script-help/m-p/1079952#M637271</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-04-11T23:19:55Z</dc:date>
    </item>
  </channel>
</rss>

