<?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: Check for consecutive records over months in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384952#M612716</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD NM_SLTT,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Date(MonthStart(Date#(Month, 'MMM/YYYY')), 'MMM/YYYY') as MonthYear;&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;NM_SLTT,Month&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jonh,Jan/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jonh,Feb/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jonh,Mar/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jonh,Apr/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mary,Jan/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mary,Feb/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mary,Apr/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ann,Jan/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ann,Mar/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ann,Apr/2017&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;STRONG&gt;TempTable:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD NM_SLTT,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MonthYear,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If(NM_SLTT = Previous(NM_SLTT) and MonthYear = MonthStart(Previous(MonthYear), 1), RangeSum(Peek('Flag'), 1), 1) as Flag&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident Table&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Order By NM_SLTT, MonthYear;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Left Join (Table)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD NM_SLTT,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If(Max(Flag) &amp;gt;= 3, 1, 0) as FinalFlag&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident TempTable&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Group By NM_SLTT;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DROP Table TempTable;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Aug 2017 13:47:27 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2017-08-25T13:47:27Z</dc:date>
    <item>
      <title>Check for consecutive records over months</title>
      <link>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384951#M612715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to check if a name appears in consecutive months and not having a tiny bit of success.&lt;/P&gt;&lt;P&gt;If the name appears in more than 2 consecutive months, I would like a true value, if not false. And this must reset every time the name doesn't appear on a month.&lt;/P&gt;&lt;P&gt;So let's say I have 3 people:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NM_SLTT,Month&lt;/P&gt;&lt;P&gt;Jonh,Jan/2017&lt;/P&gt;&lt;P&gt;Jonh,Fev/2017&lt;/P&gt;&lt;P&gt;Jonh,Mar/2017&lt;/P&gt;&lt;P&gt;Jonh,Apr/2017&lt;/P&gt;&lt;P&gt;Mary,Jan/2017&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Mary,Fev/2017&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Mary,Apr/2017&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Ann,Jan&lt;SPAN style="font-size: 13.3333px;"&gt;/2017&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Ann,Mar&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;/2017&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Ann,Apr&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;/2017&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This way, John and Ann would be true and Mary false.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried quite a few scritps. The last one is below.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;It's only working for the first NM_SLTT. All the others return 0.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Can someone give me a hand, please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TB_1:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NM_SLTT,&lt;/P&gt;&lt;P&gt;MonthNameField,&lt;/P&gt;&lt;P&gt;Count(DISTINCT NM_SLTT) as NR_PC_MES&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resident SPEND_VM&lt;/P&gt;&lt;P&gt;Where DS_CTG_SPEND = 'Condition1'&lt;/P&gt;&lt;P&gt;Group by NM_SLTT, &lt;SPAN style="font-size: 13.3333px;"&gt;MonthNameField&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Order by &lt;SPAN style="font-size: 13.3333px;"&gt;MonthNameField&lt;/SPAN&gt;, NM_SLTT DESC&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TB_2:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NM_SLTT,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;MonthNameField&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;If(NM_SLTT = Peek(NM_SLTT,-1,'TB_1'), &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If(NR_PC_MES = 1 and Peek(NR_PC_MES,-1,'TB_1') = 1, &lt;/P&gt;&lt;P&gt;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0),0) as FL_PC_CONSEC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resident TB_2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Table TB_1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 11:25:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384951#M612715</guid>
      <dc:creator />
      <dc:date>2017-08-25T11:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Check for consecutive records over months</title>
      <link>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384952#M612716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Table:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD NM_SLTT,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Date(MonthStart(Date#(Month, 'MMM/YYYY')), 'MMM/YYYY') as MonthYear;&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;NM_SLTT,Month&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jonh,Jan/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jonh,Feb/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jonh,Mar/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Jonh,Apr/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mary,Jan/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mary,Feb/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mary,Apr/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ann,Jan/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ann,Mar/2017&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ann,Apr/2017&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;STRONG&gt;TempTable:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD NM_SLTT,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MonthYear,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If(NM_SLTT = Previous(NM_SLTT) and MonthYear = MonthStart(Previous(MonthYear), 1), RangeSum(Peek('Flag'), 1), 1) as Flag&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident Table&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Order By NM_SLTT, MonthYear;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Left Join (Table)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD NM_SLTT,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;If(Max(Flag) &amp;gt;= 3, 1, 0) as FinalFlag&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Resident TempTable&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Group By NM_SLTT;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;DROP Table TempTable;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 13:47:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384952#M612716</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-08-25T13:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Check for consecutive records over months</title>
      <link>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384953#M612717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why is Ann True?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 13:49:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384953#M612717</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-08-25T13:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: Check for consecutive records over months</title>
      <link>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384954#M612718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ann is true because her name was in two consecutive months (March and April) and April was the last month we looked. If the last month was May, she would be false.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 14:17:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384954#M612718</guid>
      <dc:creator />
      <dc:date>2017-08-25T14:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Check for consecutive records over months</title>
      <link>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384955#M612719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the answer!&lt;SPAN style="text-decoration: line-through;"&gt; Althoght I am not sure it is quite what I need.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; text-decoration: line-through;"&gt;If we have more than three months (which will be the case eventually) this will not work and the count is not reseting when the name doesn't appear on a Month.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; text-decoration: line-through;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; text-decoration: line-through;"&gt;Maybe I should do a loop for each month and for each name?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I have modified my load script and am using Sunny solution now.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 14:35:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384955#M612719</guid>
      <dc:creator />
      <dc:date>2017-08-25T14:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: Check for consecutive records over months</title>
      <link>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384956#M612720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So are we looking to check for the most recent two months?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 15:38:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384956#M612720</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2017-08-25T15:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Check for consecutive records over months</title>
      <link>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384957#M612721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sunny, I've modifield my load script and used your previous solution. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for the help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 18:45:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Check-for-consecutive-records-over-months/m-p/1384957#M612721</guid>
      <dc:creator />
      <dc:date>2017-08-25T18:45:43Z</dc:date>
    </item>
  </channel>
</rss>

