<?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 RENAME in a loop problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287910#M710056</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following setup:&lt;/P&gt;&lt;P&gt;Table A loads data from an excel file, Table B loads different data from the same excel file.&lt;/P&gt;&lt;P&gt;Table A contains fields with default names (@1, @2, @3, etc), table B contains the actual names for the fields in table A.&lt;/P&gt;&lt;P&gt;I have multiple excel files to go through, so I have the renaming process in the loop that goes through all of the my files.&lt;/P&gt;&lt;P&gt;Mapping load didn't work for me, so I am working on this workaround.&lt;/P&gt;&lt;P&gt;Within the file loop, I have the RENAME loop, which looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;FOR i=0 to NoOfRows('FieldNameMap')-1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vNewFieldName = Peek('Field Name',$(i),'FieldNameMap'); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vOldFieldName = '@' &amp;amp; ($(i)+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RENAME Field '$(vOldFieldName)' to '$(vNewFieldName)';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;NEXT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This process works fine for the first excel file; however, the second time around, I can see in the debugger that the RENAME loop takes in the correct field names, but after the loop, my table still has @1, @2, @3, etc as the names of the fields!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another thing I should mention is that the tables are created at the beginning of the file loop, then one table is used as a resident table and then both the table and the map are dropped before the loop gets to NEXT, so I'm esentially starting with new tables every time I loop through with a new excel file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To sum up: why do the fields keep their names after the first file is processed?&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;Siarhei K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Jul 2011 14:53:49 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-07-18T14:53:49Z</dc:date>
    <item>
      <title>RENAME in a loop problem</title>
      <link>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287910#M710056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following setup:&lt;/P&gt;&lt;P&gt;Table A loads data from an excel file, Table B loads different data from the same excel file.&lt;/P&gt;&lt;P&gt;Table A contains fields with default names (@1, @2, @3, etc), table B contains the actual names for the fields in table A.&lt;/P&gt;&lt;P&gt;I have multiple excel files to go through, so I have the renaming process in the loop that goes through all of the my files.&lt;/P&gt;&lt;P&gt;Mapping load didn't work for me, so I am working on this workaround.&lt;/P&gt;&lt;P&gt;Within the file loop, I have the RENAME loop, which looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;FOR i=0 to NoOfRows('FieldNameMap')-1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vNewFieldName = Peek('Field Name',$(i),'FieldNameMap'); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LET vOldFieldName = '@' &amp;amp; ($(i)+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RENAME Field '$(vOldFieldName)' to '$(vNewFieldName)';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: andale mono,times;"&gt;NEXT&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This process works fine for the first excel file; however, the second time around, I can see in the debugger that the RENAME loop takes in the correct field names, but after the loop, my table still has @1, @2, @3, etc as the names of the fields!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another thing I should mention is that the tables are created at the beginning of the file loop, then one table is used as a resident table and then both the table and the map are dropped before the loop gets to NEXT, so I'm esentially starting with new tables every time I loop through with a new excel file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To sum up: why do the fields keep their names after the first file is processed?&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;Siarhei K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 14:53:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287910#M710056</guid>
      <dc:creator />
      <dc:date>2011-07-18T14:53:49Z</dc:date>
    </item>
    <item>
      <title>RENAME in a loop problem</title>
      <link>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287911#M710057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can rename all fields using a mapping tabl, you should look at the "Rename Field" entry in the help file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 16:52:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287911#M710057</guid>
      <dc:creator>danielrozental</dc:creator>
      <dc:date>2011-07-18T16:52:38Z</dc:date>
    </item>
    <item>
      <title>RENAME in a loop problem</title>
      <link>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287912#M710058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I already tried the mapping load, as I described before, but that option doesn't work for me. I am also trying to work with the rename field option, which I also described before, which is giving me a lot of trouble...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 16:59:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287912#M710058</guid>
      <dc:creator />
      <dc:date>2011-07-18T16:59:20Z</dc:date>
    </item>
    <item>
      <title>RENAME in a loop problem</title>
      <link>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287913#M710059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you share a sample application and include your data files?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 17:03:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287913#M710059</guid>
      <dc:creator>danielrozental</dc:creator>
      <dc:date>2011-07-18T17:03:31Z</dc:date>
    </item>
    <item>
      <title>RENAME in a loop problem</title>
      <link>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287914#M710060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, but I can't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was reading about other people having the issue of not being able to rename fields, and I was told that there might be an issue with me trying to rename a field with a name that is already used in another table. Don't see why that would be a problem, though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 17:26:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287914#M710060</guid>
      <dc:creator />
      <dc:date>2011-07-18T17:26:51Z</dc:date>
    </item>
    <item>
      <title>RENAME in a loop problem</title>
      <link>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287915#M710061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, that probably won't work. Can you load first the file that needs renaming?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you post your entire script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 17:51:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287915#M710061</guid>
      <dc:creator>danielrozental</dc:creator>
      <dc:date>2011-07-18T17:51:35Z</dc:date>
    </item>
    <item>
      <title>RENAME in a loop problem</title>
      <link>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287916#M710062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think I can post my entire script, sorry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did, however, confirm that the problem is trying to rename a field to create an association in a table that has already been loaded.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My workaround, to keep the field names dynamic is to create a whole bunch of variable, which keep the new field names, then when I load the table with fields that I want to rename, I use the following:&lt;/P&gt;&lt;P&gt;@1 as $(v1)&lt;/P&gt;&lt;P&gt;for example.&lt;/P&gt;&lt;P&gt;This works in my case, when I can load the new field names BEFORE I load the fields that I need to rename, and of course, if I know the exact number of fields that I will be renaming.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps somebody out there.&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;Siarhei K.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jul 2011 18:19:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/RENAME-in-a-loop-problem/m-p/287916#M710062</guid>
      <dc:creator />
      <dc:date>2011-07-18T18:19:25Z</dc:date>
    </item>
  </channel>
</rss>

