<?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 Loading data partially based on unique records and field values in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loading-data-partially-based-on-unique-records-and-field-values/m-p/300620#M710317</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to load data from a QVD file and limiting the data based on field values. This contains a WHERE statement and a PEEK statement. This is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px 'Courier New'; color: #a10000;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: #000000;"&gt;T_TRIPSTOP:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;TruckId&lt;SPAN style="color: #000000;"&gt; &amp;amp; &lt;/SPAN&gt;ShiftDate&lt;SPAN style="color: #000000;"&gt; &amp;amp; &lt;/SPAN&gt;ShiftNb&lt;SPAN style="color: #000000;"&gt;&amp;amp; &lt;/SPAN&gt;TripSequenceNb&lt;SPAN style="color: #000000;"&gt; &amp;amp; &lt;/SPAN&gt;SequenceNb&lt;SPAN style="color: #000000;"&gt; &amp;amp; &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;APPLYMAP&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;('MAPSITES', &lt;/SPAN&gt;SiteId&lt;SPAN style="color: #000000;"&gt;) &amp;amp; &lt;/SPAN&gt;Source&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;TripStopID&lt;SPAN style="color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;tTrips.QVD&lt;BR /&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;qvd&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;WHERE&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; ((&lt;/SPAN&gt;Source&lt;SPAN style="color: #000000;"&gt; = 'DC' &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;Source&lt;SPAN style="color: #000000;"&gt; = 'DP') &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;AND&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; ((&lt;/SPAN&gt;Activity&lt;SPAN style="color: #000000;"&gt; = 'Load' &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;Activity&lt;SPAN style="color: #000000;"&gt; = 'Delivery' &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;Activity&lt;SPAN style="color: #000000;"&gt; = 'StartInventory'))); &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;STRONG&gt;QUALIFY&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; *;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;STRONG&gt;UNQUALIFY&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;#TripStopID&lt;SPAN style="color: #000000;"&gt;;&amp;nbsp; &lt;BR /&gt;TRIPSTOP:&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;TripStopID&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;#TripStopID&lt;SPAN style="color: #000000;"&gt;,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;TripStopID&lt;SPAN style="color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;RESIDENT&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T_TRIPSTOP&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px 'Courier New';"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: #3300ff;"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN style="color: #a10000;"&gt;TripStopdID&lt;/SPAN&gt; &amp;lt;&amp;gt; &lt;SPAN style="color: #3300ff;"&gt;PEEK&lt;/SPAN&gt;('TripStopID'); &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px 'Courier New'; color: #a10000;"&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Right now this doens't work correct since PEEK looks at the previous record and the records are not sorted. However if I use the ORDER BY function within the first LOAD statement I get the message 'Garbage after statement'. I could put another LOAD statement in between but this seems a lot of trouble for the operation I want. Is there a smoother way to achieve the desired table: Restriction in the WHERE clause and no duplicate records from TripStopID? BTW I can't use Distinct since T_TRIPSTOP contains a lot more fields which are not all equal. Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Aug 2011 12:56:09 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-08-25T12:56:09Z</dc:date>
    <item>
      <title>Loading data partially based on unique records and field values</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-data-partially-based-on-unique-records-and-field-values/m-p/300620#M710317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to load data from a QVD file and limiting the data based on field values. This contains a WHERE statement and a PEEK statement. This is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px 'Courier New'; color: #a10000;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: #000000;"&gt;T_TRIPSTOP:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;TruckId&lt;SPAN style="color: #000000;"&gt; &amp;amp; &lt;/SPAN&gt;ShiftDate&lt;SPAN style="color: #000000;"&gt; &amp;amp; &lt;/SPAN&gt;ShiftNb&lt;SPAN style="color: #000000;"&gt;&amp;amp; &lt;/SPAN&gt;TripSequenceNb&lt;SPAN style="color: #000000;"&gt; &amp;amp; &lt;/SPAN&gt;SequenceNb&lt;SPAN style="color: #000000;"&gt; &amp;amp; &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;APPLYMAP&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;('MAPSITES', &lt;/SPAN&gt;SiteId&lt;SPAN style="color: #000000;"&gt;) &amp;amp; &lt;/SPAN&gt;Source&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;TripStopID&lt;SPAN style="color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;FROM&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;tTrips.QVD&lt;BR /&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;qvd&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;WHERE&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; ((&lt;/SPAN&gt;Source&lt;SPAN style="color: #000000;"&gt; = 'DC' &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;Source&lt;SPAN style="color: #000000;"&gt; = 'DP') &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;AND&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; ((&lt;/SPAN&gt;Activity&lt;SPAN style="color: #000000;"&gt; = 'Load' &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;Activity&lt;SPAN style="color: #000000;"&gt; = 'Delivery' &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;OR&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;Activity&lt;SPAN style="color: #000000;"&gt; = 'StartInventory'))); &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;STRONG&gt;QUALIFY&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; *;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;STRONG&gt;UNQUALIFY&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;#TripStopID&lt;SPAN style="color: #000000;"&gt;;&amp;nbsp; &lt;BR /&gt;TRIPSTOP:&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;TripStopID&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;AS&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;#TripStopID&lt;SPAN style="color: #000000;"&gt;,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;TripStopID&lt;SPAN style="color: #000000;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #3300ff;"&gt;RESIDENT&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T_TRIPSTOP&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px 'Courier New';"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: #3300ff;"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN style="color: #a10000;"&gt;TripStopdID&lt;/SPAN&gt; &amp;lt;&amp;gt; &lt;SPAN style="color: #3300ff;"&gt;PEEK&lt;/SPAN&gt;('TripStopID'); &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px 'Courier New'; color: #a10000;"&gt;&lt;SPAN style="color: #3300ff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Right now this doens't work correct since PEEK looks at the previous record and the records are not sorted. However if I use the ORDER BY function within the first LOAD statement I get the message 'Garbage after statement'. I could put another LOAD statement in between but this seems a lot of trouble for the operation I want. Is there a smoother way to achieve the desired table: Restriction in the WHERE clause and no duplicate records from TripStopID? BTW I can't use Distinct since T_TRIPSTOP contains a lot more fields which are not all equal. Thanks in advance!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 12:56:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-data-partially-based-on-unique-records-and-field-values/m-p/300620#M710317</guid>
      <dc:creator />
      <dc:date>2011-08-25T12:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Loading data partially based on unique records and field values</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-data-partially-based-on-unique-records-and-field-values/m-p/300621#M710318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As I understand, you want to load just the first occurence of every TripStopID.&lt;/P&gt;&lt;P&gt;Have you tried&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;T_TRIPSTOP:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;TruckId &amp;amp; ShiftDate &amp;amp; ShiftNb&amp;amp; TripSequenceNb &amp;amp; SequenceNb &amp;amp; APPLYMAP('MAPSITES', SiteId) &amp;amp; Source AS TripStopID,&lt;/P&gt;&lt;P&gt;Otherfields&lt;/P&gt;&lt;P&gt;FROM tTrips.QVD (qvd)&lt;/P&gt;&lt;P&gt;WHERE match(Source, 'DC', 'DP') AND match(Activity, 'Load', 'Delivery', 'StartInventory')&lt;/P&gt;&lt;P&gt;AND NOT Exists('TripStopID', TruckId &amp;amp; ShiftDate &amp;amp; ShiftNb&amp;amp; TripSequenceNb &amp;amp; SequenceNb &amp;amp; APPLYMAP('MAPSITES', SiteId) &amp;amp; Source );&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would work in QV9 and QV10SR3.&lt;/P&gt;&lt;P&gt;Earlier SRs of QV10 had buggy exists() function &lt;SPAN style="font-size: 8pt;"&gt;(see &lt;A _jive_internal="true" href="https://community.qlik.com/thread/15510"&gt;this thread&lt;/A&gt;)&lt;/SPAN&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 15:01:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-data-partially-based-on-unique-records-and-field-values/m-p/300621#M710318</guid>
      <dc:creator>tanelry</dc:creator>
      <dc:date>2011-08-25T15:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Loading data partially based on unique records and field values</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-data-partially-based-on-unique-records-and-field-values/m-p/300622#M710319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Tanel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works! However I'm not sure if I can incorporate it. For each of the TRIPSTOPS I need to Aggregate various Quantities to get the quantity for this tripstop. I use a Group by combined with an aggregation to get the desired result and Join it with the Unique records. The Group By requires a resident load which still leaves me with a temporary table. Is there a way to Aggregate over the tripstop within the initial load?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Aug 2011 16:03:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-data-partially-based-on-unique-records-and-field-values/m-p/300622#M710319</guid>
      <dc:creator />
      <dc:date>2011-08-25T16:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: Loading data partially based on unique records and field values</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-data-partially-based-on-unique-records-and-field-values/m-p/300623#M710320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try to use preceding load, something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;T_TRIPSTOP:&lt;/P&gt;&lt;P&gt;LOAD // second load: based on records returned by the preceding load statement (below)&lt;/P&gt;&lt;P&gt;TripStopID,&lt;/P&gt;&lt;P&gt;sum(Otherfield1) as Qty1,&lt;/P&gt;&lt;P&gt;sum(Otherfield2) as Qty2&lt;/P&gt;&lt;P&gt;group by TripStopID;&lt;/P&gt;&lt;P&gt;LOAD // initial load from QVD: create field TripStopID and filter records by Source and Activity&lt;/P&gt;&lt;P&gt;TruckId &amp;amp; ShiftDate &amp;amp; ShiftNb&amp;amp; TripSequenceNb &amp;amp; SequenceNb &amp;amp; APPLYMAP('MAPSITES', SiteId) &amp;amp; Source AS TripStopID,&lt;/P&gt;&lt;P&gt;Otherfield1,&lt;/P&gt;&lt;P&gt;Otherfield2&lt;/P&gt;&lt;P&gt;FROM tTrips.QVD (qvd)&lt;/P&gt;&lt;P&gt;WHERE match(Source, 'DC', 'DP') AND match(Activity, 'Load', 'Delivery', 'StartInventory');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I sometimes stack 3-4 load statements like this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Aug 2011 07:42:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-data-partially-based-on-unique-records-and-field-values/m-p/300623#M710320</guid>
      <dc:creator>tanelry</dc:creator>
      <dc:date>2011-08-26T07:42:21Z</dc:date>
    </item>
  </channel>
</rss>

