<?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: Optimisation techniques for nested ifs? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946185#M325914</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From my experience, I let the SQL handle this kind of heavy nested IFs by using CASE or in WHERE clause of the SQL script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just my 2 cents.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Oct 2015 13:33:44 GMT</pubDate>
    <dc:creator>sinanozdemir</dc:creator>
    <dc:date>2015-10-22T13:33:44Z</dc:date>
    <item>
      <title>Optimisation techniques for nested ifs?</title>
      <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946184#M325913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, so we have the following bit of code in our ETL script that has some fairly dense conditional logic. I was just wondering if anyone knew any optimisation techniques I could apply to try and optimise this? This is by fair the slowest part of our load and it would be great if I could speed it up a bit. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD *,&lt;/P&gt;&lt;P&gt; ApplyMap('LegalEntityRegion',[TLegal Entity],'remap') as [LegalEntity Region],&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; IF(Match(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [TTrade Source System],'A','B', 'C')&amp;gt;0,'V',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(isnull(LOOKUP('Flow Type','PlatformMap',TPlatform,'FlowType')),[TPlatform Description],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOOKUP('Flow Type','PlatformMap',TPlatform,'FlowType')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) &lt;/P&gt;&lt;P&gt;as [Vol Type],&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; IF([TLocal Ccy Region] = 'G10','G10',&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF([TTrade Source System]='B',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(WildMatch([TPrimary CCY],'*CNY*','*CNH*','*CNT*')&amp;gt;0,'RMB','EM')&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(WildMatch([TCurrency Pair],'*CNY*','*CNH*','*CNT*')&amp;gt;0,'RMB','EM')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&amp;nbsp; ) &lt;/P&gt;&lt;P&gt;as [Ccy Group],&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;IF([TTrade Source System] = 'C','Client', &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pick(wildMatch([TTeam Name],'Traders','Back to Back','Broker','Senior Management','Treasury - Egypt','Treasury - Kuwait','N/A','Non Users','Non Users - Research Website','Origination','*Non_Sales*', '*'), 'nonClient','nonClient','nonClient','nonClient','nonClient','nonClient','nonClient','nonClient','nonClient','nonClient','nonClient', 'Client') ) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;as [Client Flag]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resident tmpAllocationsSource&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 13:23:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946184#M325913</guid>
      <dc:creator>richnorris</dc:creator>
      <dc:date>2015-10-22T13:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation techniques for nested ifs?</title>
      <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946185#M325914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From my experience, I let the SQL handle this kind of heavy nested IFs by using CASE or in WHERE clause of the SQL script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just my 2 cents.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 13:33:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946185#M325914</guid>
      <dc:creator>sinanozdemir</dc:creator>
      <dc:date>2015-10-22T13:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation techniques for nested ifs?</title>
      <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946186#M325915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, ideally this would all be done in the database, but unfortunately that isn't an option to us at the moment. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 13:38:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946186#M325915</guid>
      <dc:creator>richnorris</dc:creator>
      <dc:date>2015-10-22T13:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation techniques for nested ifs?</title>
      <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946187#M325916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A couple of thoughts without picking it apart in detail. Lookup is notoriously slow. Try to replace that section with mapping. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 13:43:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946187#M325916</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2015-10-22T13:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation techniques for nested ifs?</title>
      <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946188#M325917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about handling all those WildMatch() functions in the Where clause of the load script? This way, Qlik will pull the necessary data from the source.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 13:44:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946188#M325917</guid>
      <dc:creator>sinanozdemir</dc:creator>
      <dc:date>2015-10-22T13:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation techniques for nested ifs?</title>
      <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946189#M325918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's difficult to say if it could be speed up significantly. An general recommendation isn't to load heavy loadings per resident load else per load from a qvd but mostly the differences aren't big. More potential should be have a replacing from the lookups() with applymap() by [Vol Type] and possibly by [Ccy Group] too respectively instead of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;IF(WildMatch([TPrimary CCY],'*CNY*','*CNH*','*CNT*')&amp;gt;0,'RMB','EM')&lt;SPAN style="font-size: 10pt;"&gt; ,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(WildMatch([TCurrency Pair],'*CNY*','*CNH*','*CNT*')&amp;gt;0,'RMB','EM')&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this one:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;IF(WildMatch([TPrimary CCY],'*CNY*','*CNH*','*CNT*')&amp;gt;0 or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WildMatch([TCurrency Pair],'*CNY*','*CNH*','*CNT*')&amp;gt;0,'RMB','EM')&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alos in your wildcard * might be potential if there are fields with a high cardinality which could be removed or splitted (like a timestamp into dates and times).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 13:58:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946189#M325918</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2015-10-22T13:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation techniques for nested ifs?</title>
      <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946190#M325919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's difficult to say without further analysis on where the bottleneck is. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd do some performance test with:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;A version of the script without the lookup (just dummy that part with a fixed value).&lt;/LI&gt;&lt;LI&gt;Same thing but dummy-ing the various wildmatch's&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See what has the most impact on performance and act on that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mapping instead of lookup seems very likely, as mentioned by Rob and Marcus above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the wildmatches, do you have some sort of "master dimension" table for fields like TPrimary or &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;TTeam Name? If so, and the number of distinct values is reasonably low, you might create a mapping table before the load, with all the possible values and the "calculated" result that they need, like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mapping map_1:&lt;/P&gt;&lt;P&gt;LOAD [&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;TPrimary CCY] as Code,&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;IF(WildMatch([TPrimary CCY],'*CNY*','*CNH*','*CNT*')&amp;gt;0,'RMB','EM') as description&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;resident Dim_&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;TPrimary_CCY&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the use a mapping instead of a wildmatch on the full-records load. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 14:34:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946190#M325919</guid>
      <dc:creator>jcamps</dc:creator>
      <dc:date>2015-10-22T14:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation techniques for nested ifs?</title>
      <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946191#M325920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Richard,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try implementing the script attached. I've broken down all conditionals into their smallest variations. It should hopefully speed up your processing significantly. I'm going to make an educated guess that your wider script could be further optimized as well based on the 'tmp' in the table name of &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;tmpAllocationsSource. If you're processing this table several times over and if it's some form of fact table, then further optimization can likely take place to reduce down the number of times you process these records. In essence, aim to have only ONE load step loading the bulk of your fact data, join on any remaining attributes and avoid conditional logic as far as possible as you're likely incurring logic processing that may have only a handful of variation of output results across 100's of millions of records.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps, kindly post some feedback either way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Jonas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 14:48:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946191#M325920</guid>
      <dc:creator>JonasValleskog</dc:creator>
      <dc:date>2015-10-22T14:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Optimisation techniques for nested ifs?</title>
      <link>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946192#M325921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, Jonas thanks! This is immense! There's a lot to pour over here, so I'm going to have to take some time to digest it. Immediately though I can see you've reduced the working set by saving off and working with distinct values, which is already a really great idea, Thank you so much for your time! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 14:59:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimisation-techniques-for-nested-ifs/m-p/946192#M325921</guid>
      <dc:creator>richnorris</dc:creator>
      <dc:date>2015-10-22T14:59:37Z</dc:date>
    </item>
  </channel>
</rss>

