<?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: calculate whether they bought it before in script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563970#M210478</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Changjun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the application that I attached to see if you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I added the following script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FinalTable:&lt;/P&gt;&lt;P&gt;LOAD *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(Peek(ITEM) = 'WATCH', 1, peek(FG_WAT))) as FG_WAT,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(Peek(ITEM) = 'SHOE', 1, peek(FG_SHOE))) as FG_SHOE,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(Peek(ITEM) = 'WALLET', 1, peek(FG_WAL))) as FG_WAL&lt;/P&gt;&lt;P&gt; Resident TempTable;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TempTable is your current table.&lt;/P&gt;&lt;P&gt;Tell me if you have any question about this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Feb 2014 04:10:11 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-02-25T04:10:11Z</dc:date>
    <item>
      <title>calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563968#M210476</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 have a problem with the calculation. I want to do it in script and I have some data like:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="ItemFlag.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/53766_ItemFlag.png" /&gt;&lt;/P&gt;&lt;P&gt;And I just want to create 3 columns -- FG_WAT, FG_SHO, FG_WAL in every row to show whether they bought watch or shoe or wallet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;before this order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for example,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the first row, the 3 flags must be 0 or didn't buy, because when order=1 ,there is no previous result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the second row, the 3 flags need to be FG_WAT=1, FG_SHOE=0, FG_WAL=0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;similarly, in the third row, the 3 flags need to be FG=WAT=1, FG_SHOW=1, FG_WAL=0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope you know what I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 02:29:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563968#M210476</guid>
      <dc:creator>uacg0009</dc:creator>
      <dc:date>2014-02-25T02:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563969#M210477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See you can add this column flag either in script or in the UI.&lt;/P&gt;&lt;P&gt;I have done it in the script have a look&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have modified your script as&amp;nbsp; below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Tab:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD * INLINE [&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VIP, ITEM, ORDER&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, WATCH, 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, SHOE, 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, SHOE, 3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, WALLET, 4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, SHOE, 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, WATCH, 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, WATCH, 3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, WATCH, 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, WATCH, 2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, SHOE, 3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, WALLET, 4&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, WALLET, 5&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;VIP, ITEM, ORDER&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;,if(ITEM='WATCH',1,0) as FG_WAT&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;,if(ITEM='WALLET',1,0) as FG_WAL&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;,if(ITEM='SHOE',1,0) as FG_SHOE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident Tab;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DROP Table Tab;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 03:52:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563969#M210477</guid>
      <dc:creator>sujeetsingh</dc:creator>
      <dc:date>2014-02-25T03:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563970#M210478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Changjun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the application that I attached to see if you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I added the following script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FinalTable:&lt;/P&gt;&lt;P&gt;LOAD *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(Peek(ITEM) = 'WATCH', 1, peek(FG_WAT))) as FG_WAT,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(Peek(ITEM) = 'SHOE', 1, peek(FG_SHOE))) as FG_SHOE,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(Peek(ITEM) = 'WALLET', 1, peek(FG_WAL))) as FG_WAL&lt;/P&gt;&lt;P&gt; Resident TempTable;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TempTable is your current table.&lt;/P&gt;&lt;P&gt;Tell me if you have any question about this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 04:10:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563970#M210478</guid>
      <dc:creator />
      <dc:date>2014-02-25T04:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563971#M210479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot drop the TempTable from the script, add in the end of script, drop table TempTable;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 04:14:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563971#M210479</guid>
      <dc:creator />
      <dc:date>2014-02-25T04:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563972#M210480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi sujeetsingh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you for your attached file, but I want to calculate whether they bought before, not this order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just when order=2, I want to know whether they bought shoe, wallet, watch before order=2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So could you have any idea to calculate that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 04:21:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563972#M210480</guid>
      <dc:creator>uacg0009</dc:creator>
      <dc:date>2014-02-25T04:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563973#M210481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Guzman has done it but i too have updated it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 04:56:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563973#M210481</guid>
      <dc:creator>sujeetsingh</dc:creator>
      <dc:date>2014-02-25T04:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563974#M210482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much, Guzman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 06:46:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563974#M210482</guid>
      <dc:creator>uacg0009</dc:creator>
      <dc:date>2014-02-25T06:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563975#M210483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, thank you for your update.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 06:47:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563975#M210483</guid>
      <dc:creator>uacg0009</dc:creator>
      <dc:date>2014-02-25T06:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563976#M210484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guzman,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I find a problem when I use the script what you gave me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because in my case, there is no this situation, but I think it will happen.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example like this when VIP = E,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="ItemFlag2.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/53777_ItemFlag2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you will see that if someone bought 2 items in one order, it will be wrong when we use peek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so how to solve this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 08:38:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563976#M210484</guid>
      <dc:creator>uacg0009</dc:creator>
      <dc:date>2014-02-25T08:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563977#M210485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi sujeetsingh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found a problem with the solution, could you please help me to solve that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the problem is like above I replied to Guzman,&lt;/P&gt;&lt;P&gt;&lt;IMG alt="ItemFlag2.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/53778_ItemFlag2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when the VIP E bought 2 things in a order, the peek can not make the flag be correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do you have any idea to solve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 08:41:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563977#M210485</guid>
      <dc:creator>uacg0009</dc:creator>
      <dc:date>2014-02-25T08:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563978#M210486</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;In your first example we can identify the real order for the orders table though the field order. Now we can have More of one item per each order. How now can we identify what item must be take before than other to calculate the flag? The order of the table at the reload or with other some rule?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I thinking perhaps if two items are ordered in same order number then in this both items flags we dont should count each and in this case we must count in the order 2 for vip e count the two items ordered previously.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What business rules we must follow?&lt;/P&gt;&lt;P&gt;Tell me if you have any question or if i must explain this.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 10:24:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563978#M210486</guid>
      <dc:creator />
      <dc:date>2014-02-25T10:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563979#M210487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guzman,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry because maybe I haven't clarified what I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And actually the order means purchase order or ,maybe I need to say, purchase sequence I think.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there is 2 items in one order, that means ,for example , VIP E, he bought 2 items in one invoice.&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;he bought SHOE and WALLET in the same time,&amp;nbsp; so the orders are all 1.&lt;/SPAN&gt;&lt;IMG alt="ItemFlag3.png" class="jive-image" src="https://community.qlik.com/legacyfs/online/53789_ItemFlag3.png" style="font-size: 10pt; line-height: 1.5em;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When we calculate the flag, the before bought means all ORDERs &amp;lt; this row's ORDER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for my poor English, let me give an example, just the VIP E.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because in the ORDER = 1 , the E bought SHOE and WALLET.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when we calculate the flags of ORDER = 2, we need to consider the two items.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the result what I want is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;VIP&amp;nbsp;&amp;nbsp; ITEM&amp;nbsp;&amp;nbsp; ORDER&amp;nbsp;&amp;nbsp; FG_WAT&amp;nbsp;&amp;nbsp; FG_SHOE&amp;nbsp;&amp;nbsp; FG_WAL&lt;/P&gt;&lt;P&gt;E&amp;nbsp;&amp;nbsp;&amp;nbsp; WATCH&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&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; 0&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; 1&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; 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do we need to add 3 flags to note what the vip bought in the same invoice? (Because the data just have 3 items)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or some better idea? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope I have clarified what I want and thank you so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 11:23:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563979#M210487</guid>
      <dc:creator>uacg0009</dc:creator>
      <dc:date>2014-02-25T11:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563980#M210488</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;Yes I think that I understood to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try with this code:&lt;/P&gt;&lt;P&gt;TempTable:&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VIP, ITEM, ORDER&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, WATCH, 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, SHOE, 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, SHOE, 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, WALLET, 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, SHOE, 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, WATCH, 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, WATCH, 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, WATCH, 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, WATCH, 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, SHOE, 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, WALLET, 4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; C, WALLET, 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; D, WATCH, 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; D, SHOE, 2 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; D, WATCH, 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; E, SHOE, 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; E, WALLET, 1 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; E, WATCH, 2&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//The TempTable must be order by VIP ID and Order ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TempTable2:&lt;/P&gt;&lt;P&gt;LOAD *,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(ORDER = Peek(ORDER), Peek(FG_WAT_TMP), if(Peek(ITEM) = 'WATCH', 1, peek(FG_WAT)))) as FG_WAT,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(ORDER = Peek(ORDER), Peek(FG_SHOE_TMP), if(Peek(ITEM) = 'SHOE', 1, peek(FG_SHOE)))) as FG_SHOE,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(ORDER = Peek(ORDER), Peek(FG_WAL_TMP), if(Peek(ITEM) = 'WALLET', 1, peek(FG_WAL)))) as FG_WAL,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(ORDER = Peek(ORDER) and Peek(ITEM) = 'WATCH', 1, peek(FG_WAT_TMP))) as FG_WAT_TMP,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(ORDER = Peek(ORDER) and Peek(ITEM) = 'SHOE', 1, peek(FG_SHOE_TMP))) as FG_SHOE_TMP,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP &amp;lt;&amp;gt; Peek(VIP), 0, if(ORDER = Peek(ORDER) and Peek(ITEM) = 'WALLET', 1, peek(FG_WAL_TMP))) as FG_WAL_TMP&lt;/P&gt;&lt;P&gt;Resident TempTable;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Table TempTable;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FinalTable:&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;&amp;nbsp; VIP,&lt;/P&gt;&lt;P&gt;&amp;nbsp; ITEM,&lt;/P&gt;&lt;P&gt;&amp;nbsp; ORDER,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP = Peek(VIP) and ORDER = Peek(ORDER), Peek(WAT),&amp;nbsp; if(FG_WAT - FG_WAT_TMP &amp;lt;&amp;gt; 0, 1, 0)) as WAT,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP = Peek(VIP) and ORDER = Peek(ORDER), Peek(SHOE),&amp;nbsp; if(FG_SHOE - FG_SHOE_TMP &amp;lt;&amp;gt; 0, 1, 0)) as SHOE,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(VIP = Peek(VIP) and ORDER = Peek(ORDER), Peek(WAL),&amp;nbsp; if(FG_WAL - FG_WAL_TMP &amp;lt;&amp;gt; 0, 1, 0)) as WAL&lt;/P&gt;&lt;P&gt;Resident TempTable2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Table TempTable2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attached a qvw.&lt;/P&gt;&lt;P&gt;Tell me if you have questions.&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 11:58:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563980#M210488</guid>
      <dc:creator />
      <dc:date>2014-02-25T11:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563981#M210489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guzman,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the late reply, because today I was checking the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I learnt a lot from your script and ideas, so thank you very very much!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I modified the script that you gave me and I think I made it better so I just want to share to you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And you also can check it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the FinalTable, I use these formulas to calculate the flags:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if(VIP = Peek(VIP) and ORDER = Peek(ORDER), Peek(WAT),&amp;nbsp; if(FG_WAT + FG_WAT_TMP &amp;gt; 0, 1, 0)) as WAT,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if(VIP = Peek(VIP) and ORDER = Peek(ORDER), Peek(SHOE),&amp;nbsp; if(FG_SHOE + FG_SHOE_TMP &amp;gt; 0, 1, 0)) as SHOE,&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;if(VIP = Peek(VIP) and ORDER = Peek(ORDER), Peek(WAL),&amp;nbsp; if(FG_WAL + FG_WAL_TMP &amp;gt; 0, 1, 0)) as WAL&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use flag add flag &amp;gt; 0, I think it is better. what do you think, Does it may cause something wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, thank you so much! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have any further questions pls tell me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2014 09:33:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563981#M210489</guid>
      <dc:creator>uacg0009</dc:creator>
      <dc:date>2014-02-26T09:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563982#M210490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Zhao,&lt;/P&gt;&lt;P&gt;What do mean by "&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;the peek can not make the flag be correct.&lt;/SPAN&gt;"?&lt;/P&gt;&lt;P&gt;Actually all the three flags present that the in the previous purchase the ITEM is present then 1 else 0.&lt;/P&gt;&lt;P&gt;How you think that the value 2 or&amp;nbsp; more can have a role in deciding this .&lt;/P&gt;&lt;P&gt;Can you please explain?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2014 10:38:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563982#M210490</guid>
      <dc:creator>sujeetsingh</dc:creator>
      <dc:date>2014-02-26T10:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: calculate whether they bought it before in script</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563983#M210491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Changjun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm glad I could help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;About your question, both solutions are similar. Is a mathematical operation and then a simple boolean question.&lt;/P&gt;&lt;P&gt;Level of performance and code, both solutions are almost the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tell me if you have any other question.&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2014 16:54:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-whether-they-bought-it-before-in-script/m-p/563983#M210491</guid>
      <dc:creator />
      <dc:date>2014-02-26T16:54:45Z</dc:date>
    </item>
  </channel>
</rss>

