<?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: for loop crosstable with differing columns in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/for-loop-crosstable-with-differing-columns/m-p/1288914#M403277</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will not work, because you are only renaming an existing column in the first line with the IF Statement you are not actually changing the Order in which the columns are loaded into Qlikview&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;if(a='1',a) as newname&lt;/P&gt;&lt;P&gt;,b,a,c,d&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// &lt;SPAN style="text-decoration: underline;"&gt;because * will still load all the columns&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest creating an Excel macro to re-arrange the columns in the workbook itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create variables with list of fields in the Order you want to load them&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;vSheet1Fields = Field3,Field1,field2,field4;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;vSheet2Fields = Field4,Field1,field2,field3; and so on&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; and use the if statement to use the fieldlist depending on the sheetname&amp;nbsp;&amp;nbsp; (/// This would still be a pain considering the number of sheets you have)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example;&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;if(Sheet1 , $(vSheet1Fields))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //// You got the point , right?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 08 Jan 2017 20:23:30 GMT</pubDate>
    <dc:creator>vinieme12</dc:creator>
    <dc:date>2017-01-08T20:23:30Z</dc:date>
    <item>
      <title>for loop crosstable with differing columns</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-crosstable-with-differing-columns/m-p/1288913#M403276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been struggling with this issue for a while looking for a solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to load in data from 55 sheets from a total of 289 sheets in an excel spreadsheet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need the all columns from the 55 sheets to be transposed into one table using the CrosstTable load function except one column from each sheet to be the qualifier field. However, the qualifier field is not always the same for each sheet. I also want to use a loop as I do not want 55 different load statements in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;A few things to consider:&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The sheets do follow a specific naming convention but they will not change&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I know the column that is required for each sheet &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have provided an extract of what I am trying below - I think the IF statement is not the right way to go about it. Any help would really be appreciated. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for each vSheet in 'S1', 'D1'&amp;nbsp; etc&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;CrossTable(x, value, 2)&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '$(vSheet)' as table,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if('$(vSheet)' = 'S1', Column1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if('$(vSheet)' = 'D1', Column2, '-')) as datafield,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[Data]&lt;/P&gt;&lt;P&gt;(ooxml, embedded labels, table is $(vSheet), filters(&lt;/P&gt;&lt;P&gt;Remove(Row, Pos(Top, 3)),&lt;/P&gt;&lt;P&gt;Remove(Row, Pos(Top, 2)),&lt;/P&gt;&lt;P&gt;Remove(Row, Pos(Top, 1)),&lt;/P&gt;&lt;P&gt;Remove(Col, Pos(Top, 1))&lt;/P&gt;&lt;P&gt;));&lt;/P&gt;&lt;P&gt;next;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Jan 2017 18:48:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-crosstable-with-differing-columns/m-p/1288913#M403276</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-01-08T18:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: for loop crosstable with differing columns</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-crosstable-with-differing-columns/m-p/1288914#M403277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will not work, because you are only renaming an existing column in the first line with the IF Statement you are not actually changing the Order in which the columns are loaded into Qlikview&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;if(a='1',a) as newname&lt;/P&gt;&lt;P&gt;,b,a,c,d&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// &lt;SPAN style="text-decoration: underline;"&gt;because * will still load all the columns&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest creating an Excel macro to re-arrange the columns in the workbook itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create variables with list of fields in the Order you want to load them&lt;/P&gt;&lt;P&gt;Example&lt;/P&gt;&lt;P&gt;vSheet1Fields = Field3,Field1,field2,field4;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;vSheet2Fields = Field4,Field1,field2,field3; and so on&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; and use the if statement to use the fieldlist depending on the sheetname&amp;nbsp;&amp;nbsp; (/// This would still be a pain considering the number of sheets you have)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example;&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;if(Sheet1 , $(vSheet1Fields))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //// You got the point , right?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Jan 2017 20:23:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-crosstable-with-differing-columns/m-p/1288914#M403277</guid>
      <dc:creator>vinieme12</dc:creator>
      <dc:date>2017-01-08T20:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: for loop crosstable with differing columns</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-crosstable-with-differing-columns/m-p/1288915#M403278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;please provide some sample data and your expected result as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Jan 2017 23:37:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-crosstable-with-differing-columns/m-p/1288915#M403278</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2017-01-08T23:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: for loop crosstable with differing columns</title>
      <link>https://community.qlik.com/t5/QlikView/for-loop-crosstable-with-differing-columns/m-p/1288916#M403279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you approach should work out. Your doubts around the IF is right - there is a better way to handle it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest using a table - either inline or from a spreadsheet or CSV-file. The following code has not been tested - just write out from the top of my head. Anyways it gives you an indication of an approach that should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14839188554385116 jive_text_macro" jivemacro_uid="_14839188554385116"&gt;
&lt;P&gt;Sheets:&lt;/P&gt;
&lt;P&gt;LOAD * INLINE [&lt;/P&gt;
&lt;P&gt;Sheet,Col&lt;/P&gt;
&lt;P&gt;Sheet1, ColC&lt;/P&gt;
&lt;P&gt;Sheet6, C2&lt;/P&gt;
&lt;P&gt;SheetB, AAA&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;
&lt;P&gt;];&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;nRows = NoOfRows('Sheets');&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;vColList ='';&lt;/P&gt;
&lt;P&gt;FOR i=1 TO nRows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vSheet = Peek('Sheet',i,'Sheets');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vCol = Peek('Col',i,'Sheets');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // pad the colums in the columnlist with @ before and after the column name, needed for correct Match later.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vColList = vColList &amp;amp; If(i=1,'',',') &amp;amp; Chr(39) &amp;amp; '@' &amp;amp; vCol &amp;amp; '@' &amp;amp; Chr(39) ;&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Temp_Data:&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CrossTable(x, value, 2)&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '$(vSheet)' AS Table,&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(Col) AS Dim,&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *&amp;nbsp;&amp;nbsp;&amp;nbsp; // Will also load the $(Col) as a data column that turns into rows, remove them in the final load&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Data.xlsx] (ooxml, embedded labels, table is $(vSheet), filters(&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remove(Row, Pos(Top, 3)),&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remove(Row, Pos(Top, 2)),&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remove(Row, Pos(Top, 1)),&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Remove(Col, Pos(Top, 1))&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ));&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;NEXT&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;
&lt;P&gt;// Exclude all the rows that were added for the double load of the Col (attribute column)&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Data:&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;LOAD * RESIDENT Temp_Data&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;WHERE Match( '@' &amp;amp; x &amp;amp; '@' , $(vColList))=0 ;&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;
&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;DROP TABLE Temp_Data;&lt;/P&gt;
&lt;/PRE&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Hope this makes sense - if not just ask me to clarify...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Jan 2017 23:41:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/for-loop-crosstable-with-differing-columns/m-p/1288916#M403279</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2017-01-08T23:41:33Z</dc:date>
    </item>
  </channel>
</rss>

