<?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: Using a Variable to determine Field Name in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1545015#M62799</link>
    <description>&lt;P&gt;You could use REname here please check its functionality in the below link&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/ScriptRegularStatements/rename-field.htm" target="_blank"&gt;https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/ScriptRegularStatements/rename-field.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;So here you can have the Excel with Changed Field names and deal with it accordingly&lt;/P&gt;</description>
    <pubDate>Fri, 15 Feb 2019 13:39:44 GMT</pubDate>
    <dc:creator>anushree1</dc:creator>
    <dc:date>2019-02-15T13:39:44Z</dc:date>
    <item>
      <title>Using a Variable to determine Field Name</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1544991#M62798</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering if it is possible to use a variable to choose what field name is necessary. The problem is a vendor sends csv files and they have changed their field name from User_Name to Employee_Name. I set up a temporary table to read which field name is used for a certain file. I then store the correct field name into a variable and load the actual table. Problem is the variable is storing 'User_Name' or 'Employee_Name' as the value of the field. Is it possible to set the field name as the variable but load in the data from the file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;For Each vFile in FileList('$(vUserTable_Source)')

Tmp:
First 1 Load
        
          if(SubStringCount(
           '|' &amp;amp; @1&amp;amp;'|' &amp;amp;  '|' &amp;amp; @2&amp;amp; '|' &amp;amp; @3&amp;amp; '|' &amp;amp; @4&amp;amp; '|' &amp;amp; @5&amp;amp; '|' &amp;amp; @6&amp;amp; '|' &amp;amp; @7&amp;amp; '|' &amp;amp; @8&amp;amp; '|' &amp;amp; @9&amp;amp; '|' &amp;amp; @10&amp;amp;
           '|' &amp;amp; @11&amp;amp; '|' &amp;amp; @12&amp;amp; '|' &amp;amp; @13&amp;amp; '|' &amp;amp; @14&amp;amp; '|' &amp;amp; @15&amp;amp; '|' &amp;amp; @16&amp;amp; '|' &amp;amp; @17&amp;amp; '|' &amp;amp; @18&amp;amp; '|' &amp;amp; @19&amp;amp; '|' &amp;amp; @20&amp;amp;
           '|' &amp;amp; @21&amp;amp; '|' &amp;amp; @22&amp;amp; '|' &amp;amp; @23&amp;amp; '|' &amp;amp; @24&amp;amp; '|' &amp;amp; @25&amp;amp; '|' &amp;amp; @26&amp;amp; '|' &amp;amp; @27&amp;amp; '|' &amp;amp; @28&amp;amp; '|' &amp;amp; @29&amp;amp; '|' &amp;amp; @30&amp;amp;
           '|' &amp;amp; @31&amp;amp; '|' &amp;amp; @32&amp;amp; '|' &amp;amp; @33&amp;amp; '|' &amp;amp; @34&amp;amp; '|' &amp;amp; @35&amp;amp; '|' &amp;amp; @36&amp;amp; '|' &amp;amp; @37&amp;amp; '|' &amp;amp; @38&amp;amp; '|' &amp;amp; @39&amp;amp; '|' &amp;amp; @40&amp;amp;
           '|' &amp;amp; @41&amp;amp; '|' &amp;amp; @42&amp;amp; '|' &amp;amp; @43&amp;amp; '|' &amp;amp; @44&amp;amp; '|' &amp;amp; @45&amp;amp; '|' &amp;amp; @46&amp;amp; '|' &amp;amp; @47&amp;amp; '|' &amp;amp; @48&amp;amp; '|' &amp;amp; @49&amp;amp; '|' &amp;amp; @50&amp;amp; '|'
          ,'|User_Name |')&amp;gt;0,'User_Name','Employee_Name') as User_Name
          
from [$(vFile)]
(txt, codepage is 28591, no labels, delimiter is ',', msq);


LET vUser_Name = PEEK('User_Name', 0, 'Tmp');

drop table Tmp;


  UserTable:

      LOAD 
          FileTime() as File_Time,
          Email,
          "Recipient Name",
          "New/Repeat Reporter",
          "Reported Phish Timestamp",
          "Time to Report (in seconds)",
          "Remote IP",
          "GeoIP Country",
          "GeoIP City",
          $(vUser_Name) as User_Name,
          BUSINESS_GROUP,
          "USERID",
          EMPLID,
          DEPTID

      FROM [$(vFile)]
      (txt, codepage is 28591, embedded labels, delimiter is ',', msq);


next vFile;&lt;/PRE&gt;</description>
      <pubDate>Sat, 16 Nov 2024 06:34:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1544991#M62798</guid>
      <dc:creator>cwitman1</dc:creator>
      <dc:date>2024-11-16T06:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable to determine Field Name</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1545015#M62799</link>
      <description>&lt;P&gt;You could use REname here please check its functionality in the below link&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/ScriptRegularStatements/rename-field.htm" target="_blank"&gt;https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/ScriptRegularStatements/rename-field.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;So here you can have the Excel with Changed Field names and deal with it accordingly&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 13:39:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1545015#M62799</guid>
      <dc:creator>anushree1</dc:creator>
      <dc:date>2019-02-15T13:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable to determine Field Name</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1545132#M62800</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Maybe you can use this approach:&lt;/P&gt;&lt;PRE&gt;// Load the two data structures
[UserTable]:
LOAD * INLINE [
File_Time, Email, "Recipient Name", "New/Repeat Reporter","Reported Phish Timestamp","Time to Report (in seconds)","Remote IP","GeoIP Country","GeoIP City",User_Name,BUSINESS_GROUP,"USERID",EMPLID,DEPTID
];


[TempEmployeeTable]:
LOAD * INLINE [
File_Time, Email, "Recipient Name", "New/Repeat Reporter","Reported Phish Timestamp","Time to Report (in seconds)","Remote IP","GeoIP Country","GeoIP City",Employee_Name,BUSINESS_GROUP,"USERID",EMPLID,DEPTID
];

// Load all your data files without specifying any field or table name
// The data from the files will land automatically in one of the data structures loaded above
For Each vFile In FileList('lib://TestData/*.csv')
	
  LOAD
  	FileTime() AS File_Time,
	*
  FROM
      [$(vFile)]
      (txt, codepage is 28591, embedded labels, delimiter is ',', msq)
  ;

Next vFile


// Now rename the TempEmployeeTable in the way that you need and drop the TempEmployeeTable
// Note you can't use RENAME FIELD [Employee_Name] TO [User_Name] in this case here because User_Name already exists
CONCATENATE([UserTable])
LOAD
    File_Time, 
    Email, 
    "Recipient Name", 
    "New/Repeat Reporter",
    "Reported Phish Timestamp",
    "Time to Report (in seconds)",
    "Remote IP",
    "GeoIP Country",
    "GeoIP City",
    Employee_Name AS User_Name,
    BUSINESS_GROUP,
    "USERID",
    EMPLID,
    DEPTID
RESIDENT
	[TempEmployeeTable]
;

DROP TABLE [TempEmployeeTable];&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mark Costa&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 15:26:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1545132#M62800</guid>
      <dc:creator>marksouzacosta</dc:creator>
      <dc:date>2019-02-15T15:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable to determine Field Name</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1545231#M62801</link>
      <description>&lt;P&gt;It may be easiest to solve this by using ALIAS.&amp;nbsp; See&amp;nbsp;&lt;A href="https://qlikviewcookbook.com/2018/12/loading-varying-column-names/" target="_blank"&gt;https://qlikviewcookbook.com/2018/12/loading-varying-column-names/&lt;/A&gt;&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>Fri, 15 Feb 2019 16:58:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1545231#M62801</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2019-02-15T16:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Variable to determine Field Name</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1545261#M62802</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6148"&gt;@rwunderlich&lt;/a&gt;&amp;nbsp;that is awesome, I didn't know about the &lt;STRONG&gt;ALIAS&lt;/STRONG&gt; statement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Mark Costa&lt;/P&gt;</description>
      <pubDate>Fri, 15 Feb 2019 18:42:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-Variable-to-determine-Field-Name/m-p/1545261#M62802</guid>
      <dc:creator>marksouzacosta</dc:creator>
      <dc:date>2019-02-15T18:42:05Z</dc:date>
    </item>
  </channel>
</rss>

