<?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: Variable in Load Scrip - Field Name in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586690#M1114679</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;You can certainly do this, but permit me to ask why? This will lead to a suboptimal model that could be awkward to work with, so unless there is a specific reason you are doing this, you would almost certainly be better off storing the date as an attribute in the fact table, rather than creating multiple value fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However you won't be able to do this in a single pass with FileBaseName as FileBaseName is only defined in a read statement and you wont be able to create a variable as used in the examples above (which are correct).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To load dynamically in this case, I would try &lt;EM&gt;For Each vFile in FileList(' &amp;lt;some folder/file mask&amp;gt; ')&lt;/EM&gt; and parse vFile for create the field name suffix variable before loading the file and then use suffix variable in the method described in the earlier posts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Feb 2014 13:04:44 GMT</pubDate>
    <dc:creator>jonathandienst</dc:creator>
    <dc:date>2014-02-14T13:04:44Z</dc:date>
    <item>
      <title>Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586685#M1114673</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'm trying to use a variable value (a date) as part of a field name in my load script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically I want the date of the file (which is part of the file name) to be part of the field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I am loading from a text file with a name like this: &lt;EM&gt;&lt;STRONG&gt;Daily_AccountExtract_DUNNS_13-FEB-2014_20140214051009.txt&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can create a field which gets the date of the file like this:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;DATE(DATE#( mid(filebasename(),28,11), 'DD-MMM-YY')) as File_Date&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to rename the [Account balance] field to [Balance as at File_Date], but cannot seem to get it right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried something like this:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;[Account balance] as "$(='Balance as at ' &amp;amp; DATE(DATE#( mid(filebasename(),28,11), 'DD-MMM-YY'))" ,&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also tried:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LET vDate = DATE(DATE#( mid(filebasename(),28,11), 'DD-MMM-YY'))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD&amp;nbsp; [Account balance] as "$(='Balance ' &amp;amp; vDate)" ,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this possible - FYI, my end goal is to be able to load multiple files with different dates, and by this method separate balance fields will be loaded for each account.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 12:44:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586685#M1114673</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2014-02-14T12:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586686#M1114675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if your field is myField and your variable is $(myVar)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;myField as 'myField'$(myVar)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 12:48:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586686#M1114675</guid>
      <dc:creator>alexandros17</dc:creator>
      <dc:date>2014-02-14T12:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586687#M1114676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt; &lt;/SPAN&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try below one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load [Account balance] &lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;as &lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt; color: #800000;"&gt;[Balance $(vDate)],...ect&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 12:53:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586687#M1114676</guid>
      <dc:creator>kumarnatarajan</dc:creator>
      <dc:date>2014-02-14T12:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586688#M1114677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this doesn't work - please see image attached.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 12:58:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586688#M1114677</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2014-02-14T12:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586689#M1114678</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;This doesn't work - the variable "vDate" is just empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think I can set the variable at the top of the load script because at that point it doesn't know yet what file I'm going to load?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 13:01:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586689#M1114678</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2014-02-14T13:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586690#M1114679</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;You can certainly do this, but permit me to ask why? This will lead to a suboptimal model that could be awkward to work with, so unless there is a specific reason you are doing this, you would almost certainly be better off storing the date as an attribute in the fact table, rather than creating multiple value fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However you won't be able to do this in a single pass with FileBaseName as FileBaseName is only defined in a read statement and you wont be able to create a variable as used in the examples above (which are correct).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To load dynamically in this case, I would try &lt;EM&gt;For Each vFile in FileList(' &amp;lt;some folder/file mask&amp;gt; ')&lt;/EM&gt; and parse vFile for create the field name suffix variable before loading the file and then use suffix variable in the method described in the earlier posts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 13:04:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586690#M1114679</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2014-02-14T13:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586691#M1114680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No single quotes. Just square brackets exactly as Kumar has suggested. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 13:05:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586691#M1114680</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2014-02-14T13:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586692#M1114681</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;It's working fine. Lead the below script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;LET &lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;&lt;STRONG&gt;&lt;EM style="color: #808080; font-size: 8pt;"&gt;vdate&lt;/EM&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;MakeDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(2012,1,1);&lt;BR /&gt;&lt;BR /&gt;Quarter:&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;LOAD&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Year&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Quarter&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;as &lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[Balance $(vdate)]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;INLINE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;[&lt;BR /&gt;Year, Quarter&lt;BR /&gt;2012, Q1&lt;BR /&gt;2012, Q2&lt;BR /&gt;2012, Q3&lt;BR /&gt;2012, Q4&lt;BR /&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 13:07:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586692#M1114681</guid>
      <dc:creator>kumarnatarajan</dc:creator>
      <dc:date>2014-02-14T13:07:11Z</dc:date>
    </item>
    <item>
      <title>Re: Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586693#M1114682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;if I understand your question&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SCRIPT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Directory;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; distinct mid(filebasename(),28,11) as File_Date&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[Daily_AccountExtract_DUNNS_13-FEB-2014_20140214051009.txt]&lt;/P&gt;&lt;P&gt;(txt, codepage is 1252, no labels, delimiter is '\t', msq);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vFile = peek('File_Date');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; @1 as [AccountBalance at $(vFile)]&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;[Daily_AccountExtract_DUNNS_13-FEB-2014_20140214051009.txt]&lt;/P&gt;&lt;P&gt;(txt, codepage is 1252, no labels, delimiter is '\t', msq);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RESULT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" height="220.77777767181396" style="width: 287.77777767181396px; height: 221.77777767181396px;" width="285.77777767181396"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl63" height="17" width="202"&gt;AccountBalance at 13-FEB-2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl64" height="17" style="border-top: none;"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 13:15:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586693#M1114682</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2014-02-14T13:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Variable in Load Scrip - Field Name</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586694#M1114683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the detailed reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be honest I am just "playing around" with a few ideas. Since you ask, here is why... &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My ultimate goal is a reduction and roll rate report which users currently do in Excel. I used balance as an example above, but the roll rate checks are firstly done using a field called [CD Status], which can have values from 1 to 9, and indicates how far a customer is in arrears on his account, CD 1 being current and CD 9 being 8 months in arrears.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our billing month is from the 11th of the month until the 10th of the next. Roll rate would then be the % of customers who were in CD1 and didn't pay and therefore "rolled" into CD2 (and so on for each CD Status). The end result, from which charts are created, would look like the attached excel images (I've blacked out company names).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Those reports are created from summary values (i.e. the total count per CD status) and they are not 100% accurate (long store why), so I want to start creating them from detail, i.e. by loading Daily Account Snaps and counting accounts that moved from 1 CD status to the next.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To do this I (might) need to keep history of what each individual account's Balance and CD Status was on different dates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like I said - just playing around for now to figure out my options.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 13:20:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-in-Load-Scrip-Field-Name/m-p/586694#M1114683</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2014-02-14T13:20:42Z</dc:date>
    </item>
  </channel>
</rss>

