<?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: Set Flag based on a value x days ago in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038780#M642301</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey &lt;A href="https://community.qlik.com/qlik-users/63925"&gt;dathu.qv&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;thanks for your reply:) I've also tested this approach and it seems to be faster than creating a lookup field and using exists.&lt;/P&gt;&lt;P&gt;By the way, what do you mean with "adding on the qvd level"? For now, I load the fact table from the qvd. After that I create the mapping table with a resident load of the fact table and perform at the end a left join with ApplyMap. That works fine:)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Jan 2016 16:51:55 GMT</pubDate>
    <dc:creator>Milo2009</dc:creator>
    <dc:date>2016-01-22T16:51:55Z</dc:date>
    <item>
      <title>Set Flag based on a value x days ago</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038774#M642295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey everybody,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the following is the initial situation. Every day QlikView is fetching new Data from a Database. The whole dataset in the QVW contains about 45.000.000 rows. So every day there will be added about 60.000 rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want to do is the following: Based on a value 7 days ago or the actual day (when the script runs), I want to set a Flag in the new records. The table illustrates my problem, the green rows are the old data and the other rows are the records I'm adding to my dataset:&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;#575757&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#FF6600&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;}" 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;}" style="border: 1px solid #000000; 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;DATE&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;ARTNR&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;VALUE&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;FLAG&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD colspan="1" style="background-color: #99cc00;"&gt;03.01.2016&lt;/TD&gt;&lt;TD colspan="1"&gt;&lt;STRONG&gt;1000&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD colspan="1"&gt;&lt;/TD&gt;&lt;TD colspan="1"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD colspan="1" style="background-color: #99cc00;"&gt;10.01.2016&lt;/TD&gt;&lt;TD colspan="1"&gt;3333&lt;/TD&gt;&lt;TD colspan="1"&gt;&lt;/TD&gt;&lt;TD colspan="1"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; background-color: #99cc00;"&gt;10.01.2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;STRONG&gt;1000&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD style="padding: 2px; background-color: #ffff00;"&gt;WP&lt;/TD&gt;&lt;TD style="padding: 2px; background-color: #ffff00;"&gt;WP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px; background-color: #99cc00;"&gt;10.01.2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2000&lt;/TD&gt;&lt;TD style="padding: 2px; background-color: #ff9900;"&gt;ZP&lt;/TD&gt;&lt;TD style="padding: 2px; background-color: #ff9900;"&gt;ZP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;17.01.2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1000&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px; background-color: #ffff00;"&gt;WP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;17.01.2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2000&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px; background-color: #ff9900;"&gt;ZP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;17.01.2016&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3333&lt;/TD&gt;&lt;TD style="padding: 2px; background-color: #99ccff;"&gt;WP&lt;/TD&gt;&lt;TD style="padding: 2px; background-color: #99ccff;"&gt;WP&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when I add new records I want QV to look 7 days back in the field 'VALUE' for the certain product and set a 'X' in the field 'FLAG', if the field 'VALUE' contains a 'WP' (yellow cells). Also I want so set a 'X' when there is just in the new record a 'WP' for the certain product (blue cells).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I could use some kind of Lookup to get the the content of the field 'VALUE', but it's taking too much time at all.&lt;/P&gt;&lt;P&gt;So do have any ideas how I could face that problem in an appropriate script runtime?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance:)&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nachricht geändert:

I've edited the table content for the field 'FLAG'.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 15:40:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038774#M642295</guid>
      <dc:creator>Milo2009</dc:creator>
      <dc:date>2016-01-20T15:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Set Flag based on a value x days ago</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038775#M642296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may try with Mapping table &amp;amp; ApplyMap&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create the mapping table:&lt;/P&gt;&lt;P&gt;Map_Flag:&lt;/P&gt;&lt;P&gt;Mapping&lt;/P&gt;&lt;P&gt;Load * INLINE [&lt;/P&gt;&lt;P&gt;Date&amp;amp;'-'Value , Flag&lt;/P&gt;&lt;P&gt;&amp;lt;use logic to generate the dates&amp;gt;&amp;amp; '-' &amp;amp; 'WP' , 1&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And use ApplyMap function to add the Flag to your fact table. You can add on the qvd level so it will not impact any performance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 17:05:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038775#M642296</guid>
      <dc:creator />
      <dc:date>2016-01-20T17:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Set Flag based on a value x days ago</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038776#M642297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How are you performing the lookup?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could do it using EXISTS() function, using something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14533101253546631" jivemacro_uid="_14533101253546631" modifiedtitle="true"&gt;
&lt;P&gt;&lt;BR /&gt;LOAD DATE, &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARTNR, &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE, &lt;BR /&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FLAG&lt;BR /&gt;&amp;nbsp; If(VALUE = 'WP',Num(DATE) &amp;amp; '-' &amp;amp; ARTNR) as Lookup,&lt;BR /&gt;&amp;nbsp; If(VALUE = 'WP' OR Exists(Lookup, Num(DATE)-7 &amp;amp; '-' &amp;amp;ARTNR),'X') as FLAG&lt;BR /&gt;FROM&lt;BR /&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;A class="jive-link-thread-small" data-containerid="2061" data-containertype="14" data-objectid="200779" data-objecttype="1" href="https://community.qlik.com/thread/200779"&gt;https://community.qlik.com/thread/200779&lt;/A&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;BR /&gt;(html, codepage is 1252, embedded labels, table is @1);&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;DROP FIELD Lookup;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 17:15:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038776#M642297</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2016-01-20T17:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Set Flag based on a value x days ago</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038777#M642298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thats sounds as a nice opportunity. With Lookup I meant the use like this:&lt;/P&gt;&lt;P&gt;Lookup('VALUE','LOOKUP', NUM(DATE)-7 &amp;amp;'-'&amp;amp; ARTNR, TABLE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I will try your idea as soon as possible:) Thanks in advance:)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 17:47:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038777#M642298</guid>
      <dc:creator>Milo2009</dc:creator>
      <dc:date>2016-01-20T17:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Set Flag based on a value x days ago</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038778#M642299</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;to create the flag for historical occurrences of "WP" you could use something like:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="QlikCommunity_Thread_200779_Pic1.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/112154_QlikCommunity_Thread_200779_Pic1.JPG" style="height: auto; width: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14533254136944526 jive_text_macro" jivemacro_uid="_14533254136944526"&gt;
&lt;P&gt;table1:&lt;/P&gt;
&lt;P&gt;LOAD DATE,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARTNR,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;FROM [&lt;/SPAN&gt;&lt;A class="jive-link-thread-small" data-containerid="2061" data-containertype="14" data-objectid="200779" data-objecttype="1" href="https://community.qlik.com/thread/200779"&gt;https://community.qlik.com/thread/200779&lt;/A&gt;&lt;SPAN&gt;] (html, codepage is 1252, embedded labels, table is @1);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Left Join (table1)&lt;/P&gt;
&lt;P&gt;LOAD DATE+7 as DATE,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARTNR,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'X' as FLAG&lt;/P&gt;
&lt;P&gt;Resident table1&lt;/P&gt;
&lt;P&gt;Where VALUE='WP';&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 21:30:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038778#M642299</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2016-01-20T21:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Set Flag based on a value x days ago</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038779#M642300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-users/15823"&gt;swuehl&lt;/A&gt; I've tested your idea and it works very good &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;For now I just can add a static 'X' as a Flag or take the content of the field 'value', when I'm just 'in the' specific row (f. ex. row 3 and 4, where I have&amp;nbsp; different flags). For this I perform a left join. How can I adjust this approach in order to get the content of the field 'value' also in the field 'Flag' in row 5 and 6 (the output should look like the table - I've adjusted the table)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jan 2016 16:48:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038779#M642300</guid>
      <dc:creator>Milo2009</dc:creator>
      <dc:date>2016-01-22T16:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Set Flag based on a value x days ago</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038780#M642301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey &lt;A href="https://community.qlik.com/qlik-users/63925"&gt;dathu.qv&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;thanks for your reply:) I've also tested this approach and it seems to be faster than creating a lookup field and using exists.&lt;/P&gt;&lt;P&gt;By the way, what do you mean with "adding on the qvd level"? For now, I load the fact table from the qvd. After that I create the mapping table with a resident load of the fact table and perform at the end a left join with ApplyMap. That works fine:)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jan 2016 16:51:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Flag-based-on-a-value-x-days-ago/m-p/1038780#M642301</guid>
      <dc:creator>Milo2009</dc:creator>
      <dc:date>2016-01-22T16:51:55Z</dc:date>
    </item>
  </channel>
</rss>

