<?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 Optimizing IF-statements for setting flags in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Optimizing-IF-statements-for-setting-flags/m-p/186785#M50741</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miguel, thank you for your reply.&lt;BR /&gt;&lt;BR /&gt;As I understand it, with one ApplyMap function I can set one predefined variable. But it is not possible to have a single ApplyMap function to point out the appropriate variable (D_3_Before, D_2_Before etc.) and set it to "1" (while the remaining 5 variables are set to null()).&lt;/P&gt;&lt;P&gt;The ApplyMap you describe, is then useful for evaluating whether DeliveredTime is any of the chosen values (-3, -2, -1, 1, 2 or 3) but it will not store which the values it was.&lt;BR /&gt;&lt;BR /&gt;Match() seems to have the same limit.&lt;BR /&gt;&lt;BR /&gt;So I don't think I in this situation can Map or Match my way to a more efficient processing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 19 Mar 2010 15:06:48 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-03-19T15:06:48Z</dc:date>
    <item>
      <title>Optimizing IF-statements for setting flags</title>
      <link>https://community.qlik.com/t5/QlikView/Optimizing-IF-statements-for-setting-flags/m-p/186783#M50739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone&lt;BR /&gt;&lt;BR /&gt;I'm currently using a lot of IF-statements to set up flags for categorizing delivery time.&lt;/P&gt;&lt;P&gt;&lt;B&gt;//Short example:&lt;/B&gt;&lt;/P&gt;&lt;P&gt;IF(DeliveredTime=-3, 1, null()) &lt;B&gt;AS&lt;/B&gt; D_3_Before,&lt;/P&gt;&lt;P&gt;IF(DeliveredTime=-2, 1, null()) &lt;B&gt;AS&lt;/B&gt; D_2_Before,&lt;/P&gt;&lt;P&gt;IF(DeliveredTime=-1, 1, null()) &lt;B&gt;AS&lt;/B&gt; D_1_Before,&lt;/P&gt;&lt;P&gt;IF(DeliveredTime=1, 1, null()) &lt;B&gt;AS&lt;/B&gt; D_1_After,&lt;/P&gt;&lt;P&gt;IF(DeliveredTime=2, 1, null()) &lt;B&gt;AS&lt;/B&gt; D_2_After,&lt;/P&gt;&lt;P&gt;IF(DeliveredTime=3, 1, null()) &lt;B&gt;AS&lt;/B&gt; D_3_After&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Since only one of these flags will be 1 and the rest will always be null(), there must be a way to optimize the run time considerably?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Frederik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 11:13:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimizing-IF-statements-for-setting-flags/m-p/186783#M50739</guid>
      <dc:creator />
      <dc:date>2010-03-19T11:13:59Z</dc:date>
    </item>
    <item>
      <title>Optimizing IF-statements for setting flags</title>
      <link>https://community.qlik.com/t5/QlikView/Optimizing-IF-statements-for-setting-flags/m-p/186784#M50740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Frederik,&lt;/P&gt;&lt;P&gt;Using ApplyMap and Maping Loads may help you to do that. Given&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;DeliverFlagMap:LOAD * INLINE [ DeliveredTime, Flag -3, 1 -2, 1 -1, 1 1, 1 2, 1 3, 1];&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;you can use then in your LOAD statement as a new field &lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;ApplyMap('DeliverFlagMap', DeliveredTime) AS FlagField&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;Now you don't need 6 fields, but one. &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Another option is the use of Match like&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;If(Match(DeliveredTime, '-3', '-2', '-1', '1', '2', '3') &amp;gt; 0, 1) AS FlagField&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Depending on what analyses you want to perform, you may want to use the above.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 11:46:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimizing-IF-statements-for-setting-flags/m-p/186784#M50740</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2010-03-19T11:46:07Z</dc:date>
    </item>
    <item>
      <title>Optimizing IF-statements for setting flags</title>
      <link>https://community.qlik.com/t5/QlikView/Optimizing-IF-statements-for-setting-flags/m-p/186785#M50741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miguel, thank you for your reply.&lt;BR /&gt;&lt;BR /&gt;As I understand it, with one ApplyMap function I can set one predefined variable. But it is not possible to have a single ApplyMap function to point out the appropriate variable (D_3_Before, D_2_Before etc.) and set it to "1" (while the remaining 5 variables are set to null()).&lt;/P&gt;&lt;P&gt;The ApplyMap you describe, is then useful for evaluating whether DeliveredTime is any of the chosen values (-3, -2, -1, 1, 2 or 3) but it will not store which the values it was.&lt;BR /&gt;&lt;BR /&gt;Match() seems to have the same limit.&lt;BR /&gt;&lt;BR /&gt;So I don't think I in this situation can Map or Match my way to a more efficient processing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Mar 2010 15:06:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Optimizing-IF-statements-for-setting-flags/m-p/186785#M50741</guid>
      <dc:creator />
      <dc:date>2010-03-19T15:06:48Z</dc:date>
    </item>
  </channel>
</rss>

