<?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: Problem using a vba custom function in the load script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480780#M691007</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I comment out the line with the VBA function then the script loads correctly and I have no issue with extra records...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Sep 2013 13:32:35 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-09-04T13:32:35Z</dc:date>
    <item>
      <title>Problem using a vba custom function in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480778#M691005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to load weather observation data but I need to an additional parameters (the wet bulb temperature) to this table. Because it is not a straight-forward calculation, rather an iteration, I need to implement a custom function defined in a vba script. The problem is that other fields in the loaded table are influenced by this vba calculation. For example, where before the load I only have 30 unique records in the field LOCATION, after the load I have 682. I have the impression that the extra records are somehow a mix of other field records. For example: "cloudy-1.03" is one new record. Another: Showers07.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the load script part:&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_13782873502708985" jivemacro_uid="_13782873502708985" modifiedtitle="true"&gt;
&lt;P&gt;WEATHER_OBSERVATIONS_TEMP:&lt;/P&gt;
&lt;P&gt;LOAD *,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOCATION,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WetBulbTemp(tempm,hum,pressurem) as TEMPERATURE_WET_BULB&lt;/P&gt;
&lt;P&gt;RESIDENT WEATHER_OBSERVATIONS_TEMP2;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the VBA code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_13782873309356837 jive_text_macro jive_macro_code" jivemacro_uid="_13782873309356837" modifiedtitle="true"&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Public Function WetBulbTemp(Ta,U,Ps)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Ta = ambient (dry bulb) air tempeature (°C)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' U = relative humidity (%)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Ps = air pressure (mBar or HPa)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Tw = intermediate result for wet bulb temperature&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' formula from &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://www.knmi.nl/samenw/geoss/avw/RIS-doc.pdf"&gt;http://www.knmi.nl/samenw/geoss/avw/RIS-doc.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' initialise wet bulb temperature and vapor pressure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; T = Ta&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; E = VaporPressure(Ta)*U&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; F = 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do while abs(F) &amp;gt;= 0.0001&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; F = (VaporPressure(T)-E)/(5419*VaporPressure(T)/(273.15+T)^2+0.000646*Ps)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T = T - F&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; E = E+0.000646*Ps*F&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; loop&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WetBulbTemp = T&lt;/P&gt;
&lt;P&gt;End Function&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Public Function VaporPressure(T)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VaporPressure = 6.11213*exp(17.5043*T/(241.2+T))&lt;/P&gt;
&lt;P&gt;End function&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone explain what is going on here? I already tried changing the vba script to:&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13782973096838167" jivemacro_uid="_13782973096838167" modifiedtitle="true"&gt;
&lt;P&gt;Public Function WetBulbTemp(Ta,U,Ps)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WetBulbTemp = 1&lt;/P&gt;
&lt;P&gt;End Function&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the problem remains...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 12:22:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480778#M691005</guid>
      <dc:creator />
      <dc:date>2013-09-04T12:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using a vba custom function in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480779#M691006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd make sure those 'new' locations don't exist in &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;WEATHER_OBSERVATIONS_TEMP2&lt;/SPAN&gt;. That's where they seem to be coming from. I don't believe in QV randomly generating values like Showers07 from nowhere.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 12:57:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480779#M691006</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-09-04T12:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using a vba custom function in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480780#M691007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I comment out the line with the VBA function then the script loads correctly and I have no issue with extra records...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 13:32:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480780#M691007</guid>
      <dc:creator />
      <dc:date>2013-09-04T13:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Problem using a vba custom function in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480781#M691008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok I have removed as much as possible in order to zoom in to the problem. The script is the following:&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_13783019716537149" jivemacro_uid="_13783019716537149" modifiedtitle="true"&gt;
&lt;P&gt;WEATHER_OBSERVATIONS_TEMP2:&lt;/P&gt;
&lt;P&gt;LOAD LOCATION as LOCATION_ORIGINAL&lt;/P&gt;
&lt;P&gt;FROM&lt;/P&gt;
&lt;P&gt;[WEATHER_OBSERVATIONS.QVD](qvd);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;NoConcatenate&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;WEATHER_OBSERVATIONS_TEMP:&lt;/P&gt;
&lt;P&gt;LOAD WetBulbTemp(1) as TEMPERATURE_WET_BULB,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOCATION_ORIGINAL as LOCATION_NEW&lt;/P&gt;
&lt;P&gt;RESIDENT WEATHER_OBSERVATIONS_TEMP2;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The VBA script is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro _jivemacro_uid_13783020806581293 jive_macro_code" jivemacro_uid="_13783020806581293"&gt;
&lt;P&gt;Public Function WetBulbTemp(Ta)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WetBulbTemp = 1&lt;/P&gt;
&lt;P&gt;End Function&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOCATION_ORIGINAL contains 27 records&lt;/P&gt;&lt;P&gt;LOCATION_NEW contains76 records&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The orginal QVD contains 553.955 records. I have tried this on 2 computers and both give me the same problem. The number of records in LOCATION_NEW fluctuates with each reload...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 13:46:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480781#M691008</guid>
      <dc:creator />
      <dc:date>2013-09-04T13:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using a vba custom function in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480782#M691009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you post that qvd file? Or create one (with sensitive data scrambled to make it unreadable) with enough data to reproduce the issue?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 13:49:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480782#M691009</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-09-04T13:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem using a vba custom function in the load script</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480783#M691010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I seem to have found a workarround. Instead of loading the QVD first and then doing all the transformations in a resident load, I've now added an extra step. The VBA script runs in a seperate resident load. So in summary:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) LOAD * FROM QVD&lt;/P&gt;&lt;P&gt;2) RESIDENT LOAD + transformations without VBA_FUNCTION &lt;/P&gt;&lt;P&gt;3) RESIDENT LOAD *, VBA_FUNCTION&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems to work fine. I believe this is a bug in QlikView somewhere. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 21:12:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-using-a-vba-custom-function-in-the-load-script/m-p/480783#M691010</guid>
      <dc:creator />
      <dc:date>2013-09-04T21:12:33Z</dc:date>
    </item>
  </channel>
</rss>

