<?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 Load For loop to load separately each file from folder // apply transformation in each file separately // then concatenate table in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Load-For-loop-to-load-separately-each-file-from-folder-apply/m-p/2412093#M94711</link>
    <description>&lt;P&gt;Hi All&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a script that was initialy load all excel files from folder&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then apply transformations ( to filter empty lines , add dimension , calculated field etc ) that was working fine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need now to use for loop statement to load each files separately to apply transformation on each file separately&amp;nbsp; then concatenate all in one simple table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The challenge here is one of the step of the transformation consist in a temp load with a where clause using variable. ( with peek function to&amp;nbsp; concat some value in a variable then use the result in a where clause )&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It occurs that for certain file I need this where clause statement but for others i do not need this where clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help me add the code to do a for loop ( with some&amp;nbsp; "for each file in ...load ...from ...&amp;nbsp; next file" )&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And also for the step with the where clause add an if statement with some think like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If ... load ... Then .... load ... end if .. to load either the temp table with the where clause or not&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And at the end concatenate in one table each file ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so to resume my need&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to load each file from folder&amp;nbsp;&lt;/P&gt;
&lt;P&gt;apply some tranformation in each of them&amp;nbsp;&lt;/P&gt;
&lt;P&gt;create value list in variable to use it in a where clause but only if this list is populated if not i don't need it&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here below my actual Code :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// load data as it is in Files&lt;BR /&gt;[brut]:&lt;BR /&gt;LOAD&lt;BR /&gt;[F1], // date et nom campagne&lt;BR /&gt;[F2], // Famille ou sous famille&lt;BR /&gt;[F5], // Volume &lt;BR /&gt;[F9], // ACL famille si idem sous famille &lt;BR /&gt;[F10], // ACL sous famille&lt;BR /&gt;[F11], //ACW famille si idem sous famille &lt;BR /&gt;[F12] // ACW sous famille&lt;BR /&gt;FROM [lib://CRC_2024 (groupe_u45410)/SUIVI_QUALIF/*_QUALIF.xls]&lt;BR /&gt;(biff, embedded labels, table is Sheet1$)&lt;BR /&gt;Where WildMatch([F1],'Campagne*','Le *') OR isnull([F1]) ;// to avoid empty some empty lines&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NoConcatenate&lt;BR /&gt;// create dimension &lt;BR /&gt;temp:&lt;/P&gt;
&lt;P&gt;Load&lt;BR /&gt;//create DATE&lt;BR /&gt;if(wildmatch(left([F1],3),'Le '),&lt;BR /&gt;date(date#(right([F1],10),'DD/MM/YYYY')),peek(DATE_JOUR)) as DATE_JOUR,&lt;/P&gt;
&lt;P&gt;// create CAMPAIN and campain ID as SDA then mother familly and child familly&lt;BR /&gt;if(wildmatch([F1],'*Campagne*'),[F1],peek(CAMPAGNE)) as CAMPAGNE,&lt;BR /&gt;if(wildmatch([F1],'*Campagne*'),Trim(left(Trim(mid([F1], 8 + 1)), 5)),peek(SDA)) as SDA,&lt;BR /&gt;if( not wildmatch([F2],'- *'),[F2],peek(Famille) ) as Famille, [F2] as sous_Famille,&lt;BR /&gt;&lt;BR /&gt;// récupére le volume &lt;BR /&gt;[F5] as Volume,&lt;/P&gt;
&lt;P&gt;//Temps de conversation (volume * acl moyen)&lt;BR /&gt;[F5]*if(wildmatch([F9],'*h*'),&lt;BR /&gt;replace(replace([F9],'h',':'),chr(39),':'),&lt;BR /&gt;replace(replace([F10],'h',':'),chr(39),':')) as TempsACL,&lt;/P&gt;
&lt;P&gt;//Temps de post appel (volume * acw moyen)&lt;BR /&gt;[F5]*if(wildmatch([F11],'*h*'),&lt;BR /&gt;replace(replace([F11],'h',':'),chr(39),':'),&lt;BR /&gt;replace(replace([F12],'h',':'),chr(39),':')) as TempsACW&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;resident brut;&lt;/P&gt;
&lt;P&gt;// need to excluse chr 39 in field Famille sous_famille to avoid further issue in variable vListeValeurKEY&lt;BR /&gt;temp1:&lt;BR /&gt;NoConcatenate&lt;BR /&gt;load &lt;BR /&gt;DATE_JOUR,&lt;BR /&gt;CAMPAGNE,&lt;BR /&gt;SDA,&lt;BR /&gt;PurgeChar(Famille,chr(39)) as Famille,&lt;BR /&gt;Purgechar(sous_Famille,chr(39)) as sous_Famille,&lt;BR /&gt;Volume,&lt;BR /&gt;TempsACL,&lt;BR /&gt;TempsACW&lt;/P&gt;
&lt;P&gt;resident temp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//temp table to create list of value for next use in where clause load with variable vListeValeurKEY&lt;BR /&gt;noconcatenate &lt;BR /&gt;VarSSFamille:&lt;BR /&gt;load &lt;BR /&gt;Famille&lt;BR /&gt;//if(wildMatch(sous_Famille,'- *'),Famille,null()) as Famille&lt;BR /&gt;resident temp1 where wildMatch(sous_Famille,'- *') and previous(Famille)=Famille;&lt;/P&gt;
&lt;P&gt;Load&lt;BR /&gt;if(wildMatch(sous_Famille,'- *'),&lt;BR /&gt;concat( distinct chr(39)&amp;amp;Famille&amp;amp;chr(39),',')) as ListeValeurKEY &lt;BR /&gt;resident VarSSFamille where not IsNull(Famille);&lt;/P&gt;
&lt;P&gt;let vListeValeurKEY =peek('ListeValeurKEY',-1,ListeValeurKEY);&lt;/P&gt;
&lt;P&gt;noconcatenate&lt;BR /&gt;// load and filter with a where clause using variable vListeValeurKEY&lt;BR /&gt;FINAL:&lt;BR /&gt;load*&lt;BR /&gt;// Resident Final&lt;BR /&gt;Resident temp1&lt;BR /&gt;where isnum(Volume) and Volume&amp;gt;0 &lt;BR /&gt;//i need this where clause if vListeValeurKEY as value , if not i don't need the where clause :&lt;BR /&gt;and not wildmatch(sous_Famille,$(vListeValeurKEY));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;drop table temp;&lt;BR /&gt;drop table temp1;&lt;BR /&gt;drop table brut;&lt;BR /&gt;drop table VarSSFamille;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jan 2024 16:21:26 GMT</pubDate>
    <dc:creator>brunobertels</dc:creator>
    <dc:date>2024-01-29T16:21:26Z</dc:date>
    <item>
      <title>Load For loop to load separately each file from folder // apply transformation in each file separately // then concatenate table</title>
      <link>https://community.qlik.com/t5/App-Development/Load-For-loop-to-load-separately-each-file-from-folder-apply/m-p/2412093#M94711</link>
      <description>&lt;P&gt;Hi All&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a script that was initialy load all excel files from folder&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then apply transformations ( to filter empty lines , add dimension , calculated field etc ) that was working fine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need now to use for loop statement to load each files separately to apply transformation on each file separately&amp;nbsp; then concatenate all in one simple table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The challenge here is one of the step of the transformation consist in a temp load with a where clause using variable. ( with peek function to&amp;nbsp; concat some value in a variable then use the result in a where clause )&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It occurs that for certain file I need this where clause statement but for others i do not need this where clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help me add the code to do a for loop ( with some&amp;nbsp; "for each file in ...load ...from ...&amp;nbsp; next file" )&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And also for the step with the where clause add an if statement with some think like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If ... load ... Then .... load ... end if .. to load either the temp table with the where clause or not&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And at the end concatenate in one table each file ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so to resume my need&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to load each file from folder&amp;nbsp;&lt;/P&gt;
&lt;P&gt;apply some tranformation in each of them&amp;nbsp;&lt;/P&gt;
&lt;P&gt;create value list in variable to use it in a where clause but only if this list is populated if not i don't need it&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here below my actual Code :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// load data as it is in Files&lt;BR /&gt;[brut]:&lt;BR /&gt;LOAD&lt;BR /&gt;[F1], // date et nom campagne&lt;BR /&gt;[F2], // Famille ou sous famille&lt;BR /&gt;[F5], // Volume &lt;BR /&gt;[F9], // ACL famille si idem sous famille &lt;BR /&gt;[F10], // ACL sous famille&lt;BR /&gt;[F11], //ACW famille si idem sous famille &lt;BR /&gt;[F12] // ACW sous famille&lt;BR /&gt;FROM [lib://CRC_2024 (groupe_u45410)/SUIVI_QUALIF/*_QUALIF.xls]&lt;BR /&gt;(biff, embedded labels, table is Sheet1$)&lt;BR /&gt;Where WildMatch([F1],'Campagne*','Le *') OR isnull([F1]) ;// to avoid empty some empty lines&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;NoConcatenate&lt;BR /&gt;// create dimension &lt;BR /&gt;temp:&lt;/P&gt;
&lt;P&gt;Load&lt;BR /&gt;//create DATE&lt;BR /&gt;if(wildmatch(left([F1],3),'Le '),&lt;BR /&gt;date(date#(right([F1],10),'DD/MM/YYYY')),peek(DATE_JOUR)) as DATE_JOUR,&lt;/P&gt;
&lt;P&gt;// create CAMPAIN and campain ID as SDA then mother familly and child familly&lt;BR /&gt;if(wildmatch([F1],'*Campagne*'),[F1],peek(CAMPAGNE)) as CAMPAGNE,&lt;BR /&gt;if(wildmatch([F1],'*Campagne*'),Trim(left(Trim(mid([F1], 8 + 1)), 5)),peek(SDA)) as SDA,&lt;BR /&gt;if( not wildmatch([F2],'- *'),[F2],peek(Famille) ) as Famille, [F2] as sous_Famille,&lt;BR /&gt;&lt;BR /&gt;// récupére le volume &lt;BR /&gt;[F5] as Volume,&lt;/P&gt;
&lt;P&gt;//Temps de conversation (volume * acl moyen)&lt;BR /&gt;[F5]*if(wildmatch([F9],'*h*'),&lt;BR /&gt;replace(replace([F9],'h',':'),chr(39),':'),&lt;BR /&gt;replace(replace([F10],'h',':'),chr(39),':')) as TempsACL,&lt;/P&gt;
&lt;P&gt;//Temps de post appel (volume * acw moyen)&lt;BR /&gt;[F5]*if(wildmatch([F11],'*h*'),&lt;BR /&gt;replace(replace([F11],'h',':'),chr(39),':'),&lt;BR /&gt;replace(replace([F12],'h',':'),chr(39),':')) as TempsACW&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;resident brut;&lt;/P&gt;
&lt;P&gt;// need to excluse chr 39 in field Famille sous_famille to avoid further issue in variable vListeValeurKEY&lt;BR /&gt;temp1:&lt;BR /&gt;NoConcatenate&lt;BR /&gt;load &lt;BR /&gt;DATE_JOUR,&lt;BR /&gt;CAMPAGNE,&lt;BR /&gt;SDA,&lt;BR /&gt;PurgeChar(Famille,chr(39)) as Famille,&lt;BR /&gt;Purgechar(sous_Famille,chr(39)) as sous_Famille,&lt;BR /&gt;Volume,&lt;BR /&gt;TempsACL,&lt;BR /&gt;TempsACW&lt;/P&gt;
&lt;P&gt;resident temp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//temp table to create list of value for next use in where clause load with variable vListeValeurKEY&lt;BR /&gt;noconcatenate &lt;BR /&gt;VarSSFamille:&lt;BR /&gt;load &lt;BR /&gt;Famille&lt;BR /&gt;//if(wildMatch(sous_Famille,'- *'),Famille,null()) as Famille&lt;BR /&gt;resident temp1 where wildMatch(sous_Famille,'- *') and previous(Famille)=Famille;&lt;/P&gt;
&lt;P&gt;Load&lt;BR /&gt;if(wildMatch(sous_Famille,'- *'),&lt;BR /&gt;concat( distinct chr(39)&amp;amp;Famille&amp;amp;chr(39),',')) as ListeValeurKEY &lt;BR /&gt;resident VarSSFamille where not IsNull(Famille);&lt;/P&gt;
&lt;P&gt;let vListeValeurKEY =peek('ListeValeurKEY',-1,ListeValeurKEY);&lt;/P&gt;
&lt;P&gt;noconcatenate&lt;BR /&gt;// load and filter with a where clause using variable vListeValeurKEY&lt;BR /&gt;FINAL:&lt;BR /&gt;load*&lt;BR /&gt;// Resident Final&lt;BR /&gt;Resident temp1&lt;BR /&gt;where isnum(Volume) and Volume&amp;gt;0 &lt;BR /&gt;//i need this where clause if vListeValeurKEY as value , if not i don't need the where clause :&lt;BR /&gt;and not wildmatch(sous_Famille,$(vListeValeurKEY));&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;drop table temp;&lt;BR /&gt;drop table temp1;&lt;BR /&gt;drop table brut;&lt;BR /&gt;drop table VarSSFamille;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2024 16:21:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Load-For-loop-to-load-separately-each-file-from-folder-apply/m-p/2412093#M94711</guid>
      <dc:creator>brunobertels</dc:creator>
      <dc:date>2024-01-29T16:21:26Z</dc:date>
    </item>
  </channel>
</rss>

