<?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 Script with flexible fields in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451271#M701621</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need to use the If..then..elseif..else..end if script statements to control the flow in your script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think you can use these within the load, so you need to create two loads, and control which load to use using &lt;/P&gt;&lt;P&gt;If..then..elseif..else..end if &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Sep 2012 08:44:25 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2012-09-28T08:44:25Z</dc:date>
    <item>
      <title>Load Script with flexible fields</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451269#M701619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to create a Qlikview document that should be able to load data from two different datasources, depending on a paramenter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My script starts like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;&lt;EM&gt;SET ProdTest = 'T';&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;&lt;EM&gt;if $(ProdTest) = 'T' then&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;&lt;EM&gt; SET Server = '\\w2k3qw2\';&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;&lt;EM&gt;else&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;&lt;EM&gt; SET Server = '\\w2k8qw4\';&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;&lt;EM&gt;end if&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I can easily change the root path from a "test" environment to a "production" envirionment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, later in the script, when loading the actual data I use this method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;i&lt;SPAN style="color: #339966;"&gt;tems:&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #339966;"&gt;load&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #339966;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemno,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #339966;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemname &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #339966;"&gt;FROM $(Server)\Qvd\items.qvd (qvd);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now to my dilemma:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The QVD in the two paths are not completely the same, the test QVD will contain columns that the prod QVD does not have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So how can I write a script that can handle this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;i&lt;SPAN style="color: #339966;"&gt;tems:&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #339966;"&gt;load&amp;nbsp; &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #339966;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemno,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #339966;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemname,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if('$(ProdTest)'='T',NewTestField,'') as NewTestField&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="color: #339966;"&gt;FROM $(Server)\Qvd\items.qvd (qvd);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it seems to not work. I dont get any error, but the field NewTestField is always blank, both for test and prod QVD.So it seems my if(...) does not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 08:22:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451269#M701619</guid>
      <dc:creator>RSvebeck</dc:creator>
      <dc:date>2012-09-28T08:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Load Script with flexible fields</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451270#M701620</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;Remove the single quotations that wrap the '$(ProdText)' in your if statement, change it from '$(ProdText)' to $(ProdText),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="background-color: #eef4f9; font-size: 12px; color: #ff0000; font-family: Arial;"&gt; if($(ProdTest)='T',NewTestField,'') as NewTestField &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="background-color: #eef4f9; font-size: 12px; color: #ff0000; font-family: Arial;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Tiong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="background-color: #eef4f9; font-size: 12px; color: #ff0000; font-family: Arial;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 08:38:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451270#M701620</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-09-28T08:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Load Script with flexible fields</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451271#M701621</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need to use the If..then..elseif..else..end if script statements to control the flow in your script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think you can use these within the load, so you need to create two loads, and control which load to use using &lt;/P&gt;&lt;P&gt;If..then..elseif..else..end if &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 08:44:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451271#M701621</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-09-28T08:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Load Script with flexible fields</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451272#M701622</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cant do that I am afraid, the present of NewTestField will trigger an error in the load even if you are not using it. You can split this into two load expressions like this:]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13488220457818230" jivemacro_uid="_13488220457818230"&gt;&lt;P&gt;If ProdTest = 'T' Then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; items:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load&amp;nbsp; itemno,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemname,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NewTestField&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM $(Server)\Qvd\items.qvd (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Else&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; items:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load itemno,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemname,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; null() As NewTestField&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM $(Server)\Qvd\items.qvd (qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;End If&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The null() is to ensure that the two load statements auto concatenate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS you could alos use LOAD * FROM .... to load all the fields, but you may have concatenation issues.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 08:47:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451272#M701622</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2012-09-28T08:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: Load Script with flexible fields</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451273#M701623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try loading the script into a variable similar to this example ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;OriginalData:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;itemno, itemname, TestField&lt;BR /&gt;A, Apples, Cooking Apples &lt;BR /&gt;B, Bananas, Small Bananas&lt;BR /&gt;C, Carrots, Baby Carrots&lt;BR /&gt;D, Duck, Duck a l'Orange&lt;BR /&gt;E, Eggs, Easter Eggs];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET ProdTest = ', TestField as TestField_new';&lt;BR /&gt;//LET ProdTest = '';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vLoadScript = &lt;BR /&gt; 'itemno as itemno_new,&lt;BR /&gt; itemname as itemname_new' &amp;amp;&lt;BR /&gt; '$(ProdTest)' &amp;amp;&lt;BR /&gt; ' resident OriginalData'; // note preceding space&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;items:&lt;BR /&gt;LOAD $(vLoadScript) ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2012 09:28:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451273#M701623</guid>
      <dc:creator>flipside</dc:creator>
      <dc:date>2012-09-28T09:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Load Script with flexible fields</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451274#M701624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tiong, but this did not help me this time. /Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 08:42:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451274#M701624</guid>
      <dc:creator>RSvebeck</dc:creator>
      <dc:date>2012-10-10T08:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Load Script with flexible fields</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451275#M701625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Stefan, I was hoping to not have to do this since I have so many tables and I wanted to find a simple elegant solution...&amp;nbsp; //Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 08:43:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451275#M701625</guid>
      <dc:creator>RSvebeck</dc:creator>
      <dc:date>2012-10-10T08:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Load Script with flexible fields</title>
      <link>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451276#M701626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the best solution. But I was hoping for a simple elegant solution and there seem to be none. All those solutions results in a script that gets complicated to read when I have a document that has 10 tables and all of them need to be able to be read from two different sources. Thanks for all help though! Appreciate it!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2012 08:47:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Load-Script-with-flexible-fields/m-p/451276#M701626</guid>
      <dc:creator>RSvebeck</dc:creator>
      <dc:date>2012-10-10T08:47:50Z</dc:date>
    </item>
  </channel>
</rss>

