<?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 for loop error in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/for-loop-error/m-p/1605239#M444666</link>
    <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;im trying to create a loop that will iterate over all item_id's that end in 'A':&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;for (RIGHT(ITEM_ID, 1) = 'A')&lt;/P&gt;&lt;P&gt;NEXT&lt;/P&gt;&lt;P&gt;can anyone tell me why this is wrong?&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 02:55:45 GMT</pubDate>
    <dc:creator>anonymous1</dc:creator>
    <dc:date>2024-11-16T02:55:45Z</dc:date>
    <item>
      <title>for loop error</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-error/m-p/1605239#M444666</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;im trying to create a loop that will iterate over all item_id's that end in 'A':&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;for (RIGHT(ITEM_ID, 1) = 'A')&lt;/P&gt;&lt;P&gt;NEXT&lt;/P&gt;&lt;P&gt;can anyone tell me why this is wrong?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 02:55:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-error/m-p/1605239#M444666</guid>
      <dc:creator>anonymous1</dc:creator>
      <dc:date>2024-11-16T02:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: for loop error</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-error/m-p/1605288#M444672</link>
      <description>&lt;P&gt;The FOR syntax does not allow a use like that - you will have to study the documentation and examples to see how FOR can be used.&lt;/P&gt;&lt;P&gt;For your specific case you might do this:&lt;/P&gt;&lt;P&gt;FOR v IN FieldValueList('ITEM_ID')&lt;BR /&gt;&amp;nbsp; IF Right(v,1)='A' THEN&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .......&lt;BR /&gt;&amp;nbsp; END IF&lt;BR /&gt;NEXT&lt;/P&gt;&lt;P&gt;The FOR can't be used while you load a table within a LOAD statement though... So without the wider context of how you intend to use it my suggestion might be useless.&lt;/P&gt;&lt;P&gt;FieldValueList() function will only give all the unique values in the field ITEM_ID and not row-wise like it is in the table(s) where the field is located.&lt;/P&gt;&lt;P&gt;This iterates through all the rows of the containing table where ITEM_ID is:&lt;BR /&gt;&lt;BR /&gt;FOR row=1 TO NoOfRows('TABLE_WHERE_ITEM_ID_IS')&lt;BR /&gt;&amp;nbsp; &amp;nbsp;IF Peek('ITEM_ID',row-1,'TABLE_WHERE_ITEM_ID_IS') THEN&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ....&lt;BR /&gt;&amp;nbsp; &amp;nbsp;END IF&lt;BR /&gt;NEXT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe this is what you need to do instead:&lt;BR /&gt;&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; If( Right(ITEM_ID,1)=A, &amp;lt;true-expression&amp;gt; , &amp;lt;false-expression&amp;gt; ) AS ResultingField,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; .....&lt;BR /&gt;FROM&lt;BR /&gt;&amp;nbsp; &amp;nbsp;....;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 17:01:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-error/m-p/1605288#M444672</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2019-07-23T17:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: for loop error</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-error/m-p/1612637#M445260</link>
      <description>&lt;P&gt;Natasha, did Petter's reply help you get things sorted?&amp;nbsp; If so, be sure to give credit by clicking the Accept as Solution.&amp;nbsp; If you did something else, please post that and mark that as the solution, so others can learn from it too.&lt;/P&gt;
&lt;P&gt;I have one thing from the Design Blog, related to Petter's comment that may help, hopefully.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/Loops-in-the-Script/ba-p/1473543" target="_blank"&gt;https://community.qlik.com/t5/Qlik-Design-Blog/Loops-in-the-Script/ba-p/1473543&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;BR /&gt;Brett&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 20:44:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-error/m-p/1612637#M445260</guid>
      <dc:creator>Brett_Bleess</dc:creator>
      <dc:date>2019-08-14T20:44:38Z</dc:date>
    </item>
  </channel>
</rss>

