<?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: Load table with same content but different column names in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514481#M599973</link>
    <description>Rob, the problem is that when doing the wildcard load, as files structures are different, different tables are created (Clients-1, Clients-2, ...), right? How to manage this?&lt;BR /&gt;</description>
    <pubDate>Thu, 29 Nov 2018 19:06:50 GMT</pubDate>
    <dc:creator>danielcapp</dc:creator>
    <dc:date>2018-11-29T19:06:50Z</dc:date>
    <item>
      <title>Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1513909#M599968</link>
      <description>&lt;P&gt;I have a folder with hundreds of Excel files (with same root name. Eg.: FileName_YYYYMMDD) that contain&amp;nbsp;similar information, but whose columns may be named differently. For example, one file contains&amp;nbsp;column name 'DealName' and the other 'DealID'.&lt;/P&gt;&lt;P&gt;Important to mention that&amp;nbsp;columns may also be in different sequence. However, there are few possible different 'layouts',&amp;nbsp;so I would like to know if there is a way to load all of them at the same time, creating conditional fields.&lt;/P&gt;&lt;P&gt;In a&amp;nbsp;logical way, I would like to do something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;LOAD

If (Exists(DealName), DealName, DealID) as DealRef

If (Exists(USDAmount), USDAmount, Amount) as DealAmount

...

FROM&amp;nbsp;[TableName]&lt;/PRE&gt;&lt;P&gt;Is there any way to doing so?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all in advance!&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 05:06:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1513909#M599968</guid>
      <dc:creator>danielcapp</dc:creator>
      <dc:date>2024-11-16T05:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1513919#M599969</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;define a subroutine or a variable with field list for those few possible "layouts".&amp;nbsp; Then load only the first line of excel file to decide which layout to use. Something like this:&lt;/P&gt;&lt;PRE&gt;//let's call this "pseudo code", just to give you an idea
SET vLayout1= DealName as DealRef, USDAmound as DealAmount;
SET vLayout2 = DealID as DealRef, Amount as DealAmount;
For Each vFile in FileList('lib://sourceDir/*.xlsx')
FirstLine:
First 1 LOAD A from [vFile] (ooxml, no labels, table is 'Sheet1');
LET vFirstFieldName = Peek('A', 0, 'FirstLine');
If ('$(vFirstFieldName)'='DealName') then
Data:
LOAD $(vLayout1) from  [vFile] (ooxml, embedded labels, table is 'Sheet1');
ElseIf('$(vFirstFieldName)'='DealID') then
Data:
LOAD $(vLayout2) from  [vFile] (ooxml, embedded labels, table is 'Sheet1');
EndIf
Drop Table FirstLine;&lt;BR /&gt;LET vFirstFieldName=;
Next vFile&lt;BR /&gt;LET vFile=;&lt;/PRE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Juraj&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 21:36:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1513919#M599969</guid>
      <dc:creator>juraj_misina</dc:creator>
      <dc:date>2018-11-28T21:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1513931#M599970</link>
      <description>&lt;P&gt;Use a set of ALIAS statements before the LOAD.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ALIAS&amp;nbsp;DealName as DealRef;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;ALIAS DealID as DealRef;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;ALIAS USDAmount as DealAmount;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You only need to ALIAS the fieldnames that require changing.&amp;nbsp; Then load your files with&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;LOAD * FROM myfile*.csv ...;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;BR /&gt;&lt;A href="http://masterssummit.com" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://qlikviewcookbook.com" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.easyqlik.com" target="_blank"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Nov 2018 22:32:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1513931#M599970</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2018-11-28T22:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514457#M599971</link>
      <description>Rob, this seems to be in the right direction. However, there another constrain that I thought wouldn't be relevant: some files have additional fields that shouldn't be considered.&lt;BR /&gt;Is there any way to 'lock' the fields to be loaded, using the ALIAS and wildcard LOAD?&lt;BR /&gt;&lt;BR /&gt;Thanks again!</description>
      <pubDate>Thu, 29 Nov 2018 17:51:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514457#M599971</guid>
      <dc:creator>danielcapp</dc:creator>
      <dc:date>2018-11-29T17:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514476#M599972</link>
      <description>&lt;P&gt;I think the most practical way would be to load all fields and then drop the fields you don't want. Something like:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ALIAS Adresse as Address;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;ALIAS Dirección as Address;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;ALIAS Estado as Status;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Clients:&lt;BR /&gt;// Load dummy field for Concatenate.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;LOAD 0 as DummyField AutoGenerate 0;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Concatenate (Clients)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;LOAD *&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;FROM addr*.csv (ansi, txt, delimiter is ',', embedded labels, msq)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DROP Field DummyField; // Drop dummy field&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;MapFieldsToKeep:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Mapping&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;LOAD *, 1 Inline [&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Fieldname&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Address&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Status&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Client&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;// Drop any fields that are not in the MapFieldsToKeep table. &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;For idx = NoOfFields('Clients') to 1 step -1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; let fname = FieldName($(idx), 'Clients');&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; if not ApplyMap('MapFieldsToKeep', '$(fname)', 0) THEN &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp; Drop Field [$(fname)];&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; EndIf &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Next idx&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;BR /&gt;&lt;A href="http://masterssummit.com" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://qlikviewcookbook.com" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.easyqlik.com" target="_blank"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 20:25:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514476#M599972</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2018-11-29T20:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514481#M599973</link>
      <description>Rob, the problem is that when doing the wildcard load, as files structures are different, different tables are created (Clients-1, Clients-2, ...), right? How to manage this?&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Nov 2018 19:06:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514481#M599973</guid>
      <dc:creator>danielcapp</dc:creator>
      <dc:date>2018-11-29T19:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514488#M599974</link>
      <description>Oh, got your solution now! Very clever...&lt;BR /&gt;However, the DROP part is not working, it tries to drop empty field names and generate several errors. Any clue?</description>
      <pubDate>Thu, 29 Nov 2018 19:20:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514488#M599974</guid>
      <dc:creator>danielcapp</dc:creator>
      <dc:date>2018-11-29T19:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514489#M599975</link>
      <description>&lt;P&gt;Take a look at your document log to see what the steps in the loop look like.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 19:21:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514489#M599975</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2018-11-29T19:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514504#M599976</link>
      <description>&lt;P&gt;Execution looks weird. Below is my code:&lt;/P&gt;&lt;PRE&gt;ALIAS DealID as FXAthenaDealName;
ALIAS InstrumentType as FXAthenaInstrumentType;
ALIAS TradeDate as FXAthenaTradeDate;
ALIAS ExpirationDate as FXAthenaExpirationDate;
ALIAS SettlementDate as FXAthenaSettlementDate;

FXData:
LOAD 0 as DummyField AutoGenerate 0; // Load dummy field for Concatenate. 
Concatenate (FXData)
LOAD *
FROM
[filename*.xlsx]
(ooxml, embedded labels);


DROP Field DummyField; // Drop dummy field

MapFieldsToKeep:
Mapping
LOAD *, 1 Inline [
FXAthenaDealName
FXAthenaInstrumentType
FXAthenaTradeDate
FXAthenaExpirationDate
FXAthenaSettlementDate
]
;

// Drop any fields that are not in the MapFieldsToKeep table. 
For idx = 1 to NoOfFields('FXData')
	let fname = FieldName($(idx), 'FXData');
	if Len('$(fname)')&amp;gt;0 THEN
		if not ApplyMap('MapFieldsToKeep', '$(fname)', 0) THEN 
			Drop Field [$(fname)] From FXData;
		EndIf
	ENDIF
Next idx&lt;/PRE&gt;&lt;P&gt;See that I included the 'Len' check as there I suspected some files contained columns with trash and were being loaded with empty field names. However, what I see in log file (attached here)&amp;nbsp;is that some fields are not being dropped because during the loop their field names are being treated as an empty string (check the final&amp;nbsp;lines of log file). However, when the execution ends, the fields are available in their original names, as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Table.PNG" style="width: 477px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/1310i3BB52A71009DD01A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Table.PNG" alt="Table.PNG" /&gt;&lt;/span&gt;Look for these fields (AprilID, CorpMV) in the log file. They are being loaded, but not dropped.&lt;/P&gt;&lt;P&gt;Am I missing something?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 20:01:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514504#M599976</guid>
      <dc:creator>danielcapp</dc:creator>
      <dc:date>2018-11-29T20:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514509#M599977</link>
      <description>&lt;P&gt;My bad for doing limited testing.&amp;nbsp; Change your&amp;nbsp;for loop to process fields from end of the list backwards:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;For idx = NoOfFields('Clients') to 1 step -1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've updated my sample above.&amp;nbsp; Reason being that when you drop fields you are changing the remaining field numbers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;BR /&gt;&lt;A href="http://masterssummit.com" target="_blank"&gt;http://masterssummit.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://qlikviewcookbook.com" target="_blank"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.easyqlik.com" target="_blank"&gt;http://www.easyqlik.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2018 20:27:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1514509#M599977</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2018-11-29T20:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1515694#M599978</link>
      <description>&lt;P&gt;Working perfectly now Rob, thanks!! Do you want to repost your answer with this correction so I can mark it as solution?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Capp&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 15:13:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1515694#M599978</guid>
      <dc:creator>danielcapp</dc:creator>
      <dc:date>2018-12-03T15:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Load table with same content but different column names</title>
      <link>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1515902#M599979</link>
      <description>&lt;P&gt;Glad to hear it's working.&amp;nbsp; I did edit my previous post with the correction, so you can mark that one as correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 01:58:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-table-with-same-content-but-different-column-names/m-p/1515902#M599979</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2018-12-04T01:58:36Z</dc:date>
    </item>
  </channel>
</rss>

