<?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: Calling Subs within Loads to return value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305604#M618808</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To help you get started, see this example: &lt;A href="https://community.qlik.com/docs/DOC-3883"&gt;Using Macro functions in Script&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The non-standard function NextContractDate() is actually a user-defined macro function. See QV Desktop-&amp;gt;Tools-&amp;gt;Edit Module...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Apr 2017 08:49:05 GMT</pubDate>
    <dc:creator>Peter_Cammaert</dc:creator>
    <dc:date>2017-04-25T08:49:05Z</dc:date>
    <item>
      <title>Calling Subs within Loads to return value</title>
      <link>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305598#M618802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working on a solution and have put the pseudo code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subroutine 1&lt;/P&gt;&lt;P&gt;Define vResc as Number&lt;/P&gt;&lt;P&gt;ApplyMapLOT Site&lt;/P&gt;&lt;P&gt;Define vSite as Site&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subroutine 2&lt;/P&gt;&lt;P&gt;Define vResc as Number&lt;/P&gt;&lt;P&gt;ApplyMapNUMBER Site&lt;/P&gt;&lt;P&gt;Define vSite as Site&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If Number = vResc then vSite&lt;/P&gt;&lt;P&gt;else Call Subroutine 1 (returns vSite)&lt;/P&gt;&lt;P&gt;else Call Subroutine 2 (returns vSite) as Site.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My aim is to give all the same numbers the same site regardless if a lot exists or not.&amp;nbsp; Desired outlook is in the table.&lt;/P&gt;&lt;P&gt;Subroutine 1 does the applymap on the log to return the site.&amp;nbsp; It also assigns the number to a variable and the site to a variable.&lt;/P&gt;&lt;P&gt;Subroutine 2 does the applymap on the number to return the site.&amp;nbsp; It also assigns the number to a variable and the site to a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the next number is equal to the vResc variable then the vSite variable is used as the site for that row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#000000&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;,&amp;quot;verticalAlign&amp;quot;:&amp;quot;baseline&amp;quot;}" style="border: 1px solid #000000; border-image: none; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Number&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="padding: 2px; text-align: center; color: #ffffff; font-family: arial,helvetica,sans-serif; vertical-align: baseline; background-color: #6690bc;"&gt;&lt;STRONG&gt;Lot&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="padding: 2px; text-align: center; color: #ffffff; font-family: arial,helvetica,sans-serif; vertical-align: baseline; background-color: #6690bc;"&gt;&lt;STRONG&gt;Site&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;abc123&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;London&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;abc456&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;London&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;London&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;acb213&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;Paris&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;cba321&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;Madrid&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;Madrid&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;4&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px; text-align: left; color: #000000;"&gt;Rome&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hope this makes sense - Subroutines might not be the right way to code this but not overly experienced in QV.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Let vResc = '';&lt;BR /&gt;Let vSite = '';&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Sub AssignSite1&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Let vResc = Number;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt; SiteMethod: &lt;BR /&gt; LOAD if(not ISNULL(Lot),ApplyMap('PSMAP', Lot, 'Lot Without Map')) as MfgSite&lt;BR /&gt; ;&lt;BR /&gt;Let vSite = MfgSite;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;ENDSUB; &lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;BR /&gt;SUB AssignSite2&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Let vResc = Number;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; if(isNull(Lot), ApplyMap('MaskMapOne', Number, 'Multi-Site')) as MfgSite;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Let vSite = MfgSite;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;ENDSUB; &lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;BR /&gt;Map_Applied:&lt;BR /&gt;Load&lt;BR /&gt;&amp;nbsp; Number,&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; Lot,&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp; Description,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(Number = vResc, vSite,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(Number &amp;lt;&amp;gt; vResc, CALL AssignSite1, CALL AssignSite2 )) as MfgSite&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Resident Stock_Data;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Drop Table Stock_Data; &lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2017 09:52:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305598#M618802</guid>
      <dc:creator>tom2qlik</dc:creator>
      <dc:date>2017-04-24T09:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Subs within Loads to return value</title>
      <link>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305599#M618803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;COuld you post your app ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and try&lt;/P&gt;&lt;P&gt;Map_Applied:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;&amp;nbsp; Number,&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; Lot,&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; Description,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(Number = vResc, vSite,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(Number &amp;lt;&amp;gt; vResc, if(not ISNULL(Lot),ApplyMap('PSMAP', Lot, 'Lot Without Map'))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,if (isNull(Lot), ApplyMap('MaskMapOne', Number, 'Multi-Site'))&amp;nbsp; )) as MfgSite&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Resident Stock_Data;&lt;/P&gt;&lt;P&gt;Drop Table Stock_Data;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you are not suppose to use subroutine inside the expression.&lt;/P&gt;&lt;P&gt;you can also use function pick instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2017 10:43:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305599#M618803</guid>
      <dc:creator>annafuksa1</dc:creator>
      <dc:date>2017-04-24T10:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Subs within Loads to return value</title>
      <link>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305600#M618804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot CALL SubRoutines from inside a LOAD statement, you can only use functions (just like any QlikView function). SubRoutines don't return values, only functions do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Redefine your code as a set of macro functions that return values and use them - without the CALL keyword - in a LOAD statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW CALL is a statement keyword. You cannot embed other statements in a LOAD...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2017 10:47:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305600#M618804</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2017-04-24T10:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Subs within Loads to return value</title>
      <link>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305601#M618805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your response.&lt;/P&gt;&lt;P&gt;I can post the app but there is little more detail on it than what I've posted and I can't post the full app because of sensitive data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have thought of your solution however How will the variable be assigned a new value?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The next number in the source table will always be different so the second condition in the if statement will always be met which is not the required outcome.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need the variable vResc to change to with every new number for this method to work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2017 11:24:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305601#M618805</guid>
      <dc:creator>tom2qlik</dc:creator>
      <dc:date>2017-04-24T11:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Subs within Loads to return value</title>
      <link>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305602#M618806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to see the data and be able to test my solution &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;I just look at this and make a changes to code but was not able to test it so may have some little problems -it was just to give you idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for variable you can choose function Peek or maybe you&amp;nbsp; may need to create function&amp;nbsp; for this case&lt;/P&gt;&lt;P&gt;its a little difficult to say now&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;but it can be easier if you will post as well expecting result with current app&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2017 12:38:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305602#M618806</guid>
      <dc:creator>annafuksa1</dc:creator>
      <dc:date>2017-04-24T12:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Subs within Loads to return value</title>
      <link>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305603#M618807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this is probably the closest answer I am going to get as to if this solution will work.&amp;nbsp; Thanks for clarifying that CALLs can't be used within Loads.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have not used macros in Qlikview before so thanks for bringing them to my attention.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Apr 2017 08:12:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305603#M618807</guid>
      <dc:creator>tom2qlik</dc:creator>
      <dc:date>2017-04-25T08:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calling Subs within Loads to return value</title>
      <link>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305604#M618808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To help you get started, see this example: &lt;A href="https://community.qlik.com/docs/DOC-3883"&gt;Using Macro functions in Script&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The non-standard function NextContractDate() is actually a user-defined macro function. See QV Desktop-&amp;gt;Tools-&amp;gt;Edit Module...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Apr 2017 08:49:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calling-Subs-within-Loads-to-return-value/m-p/1305604#M618808</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2017-04-25T08:49:05Z</dc:date>
    </item>
  </channel>
</rss>

