<?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: Create a loop with variable in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1912062#M75175</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Because the next time the loop runs I want to bolt the next value on the end to build the bit of the string that will form the list to run the wildmatch against.&lt;/P&gt;
&lt;P&gt;So i=0 I get &lt;STRONG&gt;'rec*', (&lt;/STRONG&gt;appended to the empty string), then when i=1 appends &lt;STRONG&gt;'test*',&lt;/STRONG&gt; giving &lt;STRONG&gt;'rec*,'test*', &lt;/STRONG&gt;(the final comma explains why we need the Left in vVar function).&lt;/P&gt;
&lt;P&gt;Does that help?&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Chris.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2022 17:30:16 GMT</pubDate>
    <dc:creator>chrismarlow</dc:creator>
    <dc:date>2022-03-30T17:30:16Z</dc:date>
    <item>
      <title>Create a loop with variable</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1909899#M74985</link>
      <description>&lt;P&gt;Hello QLik team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following variables&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LET vL.NomAppPrefixeNIV3 = UPPER(TEXT(Pick(wildmatch(DocumentTitle(),&lt;BR /&gt;'rec*','test*','niv3*','*suivi*Objectif*','*challenge*','*backlog*','*pilotage*commercial*','*achats*','*buca*')&lt;BR /&gt;,'rec_','test','niv3','Suiv','CHAL','BACK','Pilo','ACHA','BUCA')));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;II.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;LET vL.EnvironnementNIV3 = pick(Match('$(vL.NomAppPrefixeNIV3)','REC_','TEST','NIV3','SUIV','CHAL','BACK','PILO','ACHA','BUCA'),&lt;BR /&gt;'lib://Données AS400 - Rec:DataFiles','lib://Données AS400 - Test:DataFiles','lib://Données AS400:DataFiles','lib://Données AS400:DataFiles','lib://Données AS400:DataFiles',&lt;BR /&gt;'lib://Données AS400:DataFiles','lib://Données AS400:DataFiles','lib://Données AS400:DataFiles','lib://Données AS400:DataFiles'); //Environnement &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of adding values every time in each variables i would like to create a straight table (xls format with each values&lt;/P&gt;
&lt;P&gt;First column variable and 2nd column values (for one variable there are N values).&lt;/P&gt;
&lt;P&gt;I would like to create a statement like for i to n values&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;So that it can take into account each values&lt;/P&gt;
&lt;P&gt;Anyone has an idea on how to do this ?&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 14:34:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1909899#M74985</guid>
      <dc:creator>random_user_3869</dc:creator>
      <dc:date>2022-03-25T14:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create a loop with variable</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1910002#M74988</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I think the loop would look a bit like this;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;data:
Load * Inline [
Match, Return
rec*, rec_
test*, test
];

Let vMatch='';
Let vReturn='';

for i=0 to NoOfRows('data')-1
	
	LET vMatch=vMatch&amp;amp;''''&amp;amp;peek('Match',i,'data')&amp;amp;''',';
	LET vReturn=vReturn&amp;amp;''''&amp;amp;peek('Return',i,'data')&amp;amp;''',';

next

LET vVar='UPPER(TEXT(Pick(wildmatch(DocumentTitle(),'&amp;amp;Left(vMatch,Len(vMatch)-1)&amp;amp;'),'&amp;amp;Left(vReturn,Len(vReturn)-1)&amp;amp;')';&lt;/LI-CODE&gt;
&lt;P&gt;You would want to point the load at the spreadsheet, but you can get that through the data connection wizards.&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Chris.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 17:46:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1910002#M74988</guid>
      <dc:creator>chrismarlow</dc:creator>
      <dc:date>2022-03-25T17:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Create a loop with variable</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1911977#M75169</link>
      <description>&lt;P&gt;Thank you for the reply&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can you explain to me this:&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-javascript"&gt;&lt;CODE&gt;LET vMatch=vMatch&amp;amp;''''&amp;amp;peek('Match',i,'data')&amp;amp;''',';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't understand why you put vMatch at the begining if the value is 0&lt;/P&gt;
&lt;P&gt;why put vMatch&amp;amp;''''&amp;amp; instead of ONLY peek('Match',i,'data)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 15:07:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1911977#M75169</guid>
      <dc:creator>random_user_3869</dc:creator>
      <dc:date>2022-03-30T15:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create a loop with variable</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1912062#M75175</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Because the next time the loop runs I want to bolt the next value on the end to build the bit of the string that will form the list to run the wildmatch against.&lt;/P&gt;
&lt;P&gt;So i=0 I get &lt;STRONG&gt;'rec*', (&lt;/STRONG&gt;appended to the empty string), then when i=1 appends &lt;STRONG&gt;'test*',&lt;/STRONG&gt; giving &lt;STRONG&gt;'rec*,'test*', &lt;/STRONG&gt;(the final comma explains why we need the Left in vVar function).&lt;/P&gt;
&lt;P&gt;Does that help?&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Chris.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 17:30:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1912062#M75175</guid>
      <dc:creator>chrismarlow</dc:creator>
      <dc:date>2022-03-30T17:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create a loop with variable</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1912287#M75189</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again for your insight.&lt;/P&gt;
&lt;P&gt;What i need to know is for i= 0 what is the result of this:&lt;/P&gt;
&lt;P&gt;LET vMatch=&lt;STRONG&gt;vMatch&lt;/STRONG&gt;&amp;amp;''''&amp;amp;peek('Match',i,'data')&amp;amp;''',';&lt;/P&gt;
&lt;P&gt;AND this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LET vReturn=&lt;STRONG&gt;vReturn&lt;/STRONG&gt;&amp;amp;''''&amp;amp;peek('Return',i,'data')&amp;amp;''',';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because as you put the following values&lt;/P&gt;
&lt;P&gt;Let vMatch='';&lt;BR /&gt;Let vReturn='';&amp;nbsp; before the variable statement basically what i understand is for i = 0&amp;nbsp;&lt;/P&gt;
&lt;P&gt;==&amp;gt;&amp;nbsp;LET vMatch=&lt;STRONG&gt;vMatch&lt;/STRONG&gt;&amp;amp;''''&amp;amp;peek('Match',i,'data')&amp;amp;''','; ==&amp;gt;&amp;nbsp;LET vMatch=&lt;STRONG&gt;peek&lt;/STRONG&gt;('Match',i,'data')&amp;amp;''',';&lt;/P&gt;
&lt;P&gt;because&amp;nbsp;Let vMatch='';&lt;/P&gt;
&lt;P&gt;Basically i don't understand the use of saying LET vExample = vExample &amp;amp;peek(Field,i,Table). Can't you jsut put&amp;nbsp;&lt;/P&gt;
&lt;P&gt;peek(Field,i,Table) ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And about the following:&amp;nbsp;LET vVar=UPPER(TEXT(Pick(wildmatch(DocumentTitle(),'&amp;amp;Left(vMatch,Len(vMatch)-1)&amp;amp;'),'&amp;amp;Left(vReturn,Len(vReturn)-1)&amp;amp;');&lt;/P&gt;
&lt;P&gt;Basically for&amp;nbsp;Len(vMatch)-1) means if len(text) =4 then len(text)-1 = 3 right ?&lt;/P&gt;
&lt;P&gt;Thank you for your help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 08:00:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1912287#M75189</guid>
      <dc:creator>random_user_3869</dc:creator>
      <dc:date>2022-03-31T08:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create a loop with variable</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1912388#M75197</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;If you just put peek() in without the vExample&amp;amp; then when it finishes running you are just going to get the last value in vExample (i.e. from the last row in the data), rather than all the values concatenated together (with quotes and commas, so works a a list).&lt;/P&gt;
&lt;P&gt;If you can put debugging on maybe step through line by line, with something with vExample&amp;amp; and something without, and that will help?&lt;/P&gt;
&lt;P&gt;The final point on len() - yes that is right - and the reason it is there is that otherwise there will be a trailing comma.&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Chris.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 10:20:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-loop-with-variable/m-p/1912388#M75197</guid>
      <dc:creator>chrismarlow</dc:creator>
      <dc:date>2022-03-31T10:20:43Z</dc:date>
    </item>
  </channel>
</rss>

