<?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: Compacting a table so I can join it into my data_model? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447604#M695131</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// ---- create sample data:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;costTable:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; item&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,date#(cost_date,'YYYY-MM-DD') as cost_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,cost&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;INLINE [&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; item, cost_date, cost&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, 2012-01-01, 12&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, 2013-01-01, 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, 2011-06-14, 13&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, 2012-09-10, 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, 2013-03-01, 11&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// ---- right join with maximum cost_date values &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;right join load item, max(cost_date) as cost_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;resident costTable group by item;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// ---- done &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 May 2013 11:37:30 GMT</pubDate>
    <dc:creator>Gysbert_Wassenaar</dc:creator>
    <dc:date>2013-05-10T11:37:30Z</dc:date>
    <item>
      <title>Compacting a table so I can join it into my data_model?</title>
      <link>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447600#M695127</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;I have a table I would like to include into my data_model just for one field - but the field which I can use as joinfield is not unique. There is a date component, so I have to select the most current (biggest date-time-stamp) value per keyfield. I need the field PACKING_PLAN_DETAIL.QUANTITY and the datefield I have to use is BUSINESS_PLAN.CREATION_DATE.&lt;/P&gt;&lt;P&gt;can somebody help me with the SET_analysis syntax I need to do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have just read up in "QlikView 11 for Developers" and it should be like that - well, obviously not quite for it doesn't work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; LOAD&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;{$&amp;lt;BUSINESS_PLAN.CREATION_DATE = {$(=Max(BUSINESS_PLAN.CREATION_DATE))}&amp;gt;} PACKING_PLAN_DETAIL.QUANTITY&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 09:27:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447600#M695127</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-05-10T09:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Compacting a table so I can join it into my data_model?</title>
      <link>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447601#M695128</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;set Analysis works in expression not in script&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 09:29:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447601#M695128</guid>
      <dc:creator>er_mohit</dc:creator>
      <dc:date>2013-05-10T09:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Compacting a table so I can join it into my data_model?</title>
      <link>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447602#M695129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi er.mohit,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;there seems to be something wrong still: Examining that field in the table_viewer_window tells me it is populated in every record - but when I put it into my diagram (the formula), I don't get a value at all.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 10:16:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447602#M695129</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-05-10T10:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Compacting a table so I can join it into my data_model?</title>
      <link>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447603#M695130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this technique which you can use in your load script:&lt;/P&gt;&lt;P&gt;(you obviously need to adapt it to your tables)&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 _jivemacro_uid_13681853275917036" jivemacro_uid="_13681853275917036"&gt;&lt;P&gt;// create sample data:&lt;/P&gt;&lt;P&gt;costTable:&lt;/P&gt;&lt;P&gt;LOAD * INLINE [&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; item, cost_date, cost&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, 2012-01-01, 12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, 2013-01-01, 15&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, 2011-06-14, 13&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, 2012-09-10, 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, 2013-03-01, 11&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// ------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Find the max data value for eacj item and create a combined field&lt;/P&gt;&lt;P&gt;_maxCostDatePerItem:&lt;/P&gt;&lt;P&gt;LOAD item&amp;amp;'@'&amp;amp;Date(max(cost_date)) As items_max_cost_date&lt;/P&gt;&lt;P&gt;Resident costTable&lt;/P&gt;&lt;P&gt;Group By item;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Get Data for the row that matches the combined field (that is what the Exists() function&amp;nbsp; do)&lt;/P&gt;&lt;P&gt;currentCosts:&lt;/P&gt;&lt;P&gt;LOAD item,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cost,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cost_date As cost_effective_since_date&lt;/P&gt;&lt;P&gt;Resident costTable&lt;/P&gt;&lt;P&gt;Where Exists(items_max_cost_date,item&amp;amp;'@'&amp;amp;cost_date);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DROP Tables _maxCostDatePerItem, costTable; // Clean up any tables you dont need anymore (optional)&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 11:28:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447603#M695130</guid>
      <dc:creator>gandalfgray</dc:creator>
      <dc:date>2013-05-10T11:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Compacting a table so I can join it into my data_model?</title>
      <link>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447604#M695131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// ---- create sample data:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;costTable:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; item&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,date#(cost_date,'YYYY-MM-DD') as cost_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,cost&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;INLINE [&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; item, cost_date, cost&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, 2012-01-01, 12&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; A, 2013-01-01, 15&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, 2011-06-14, 13&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, 2012-09-10, 10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; B, 2013-03-01, 11&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// ---- right join with maximum cost_date values &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;right join load item, max(cost_date) as cost_date&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;resident costTable group by item;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// ---- done &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 11:37:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447604#M695131</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-05-10T11:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Compacting a table so I can join it into my data_model?</title>
      <link>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447605#M695132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gysbert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your idea seemed very good - simple, and it would give me a new table where the keyfield ITEM_Nr should be unique and which I could thus join to another table to keep my data_model compact.&lt;/P&gt;&lt;P&gt;Unfortunately, however, it does not work:; After writing this new code (adapted of course) and reloading the script, that table has the same nr. of records it had before and my keyfield is still not unique...&lt;/P&gt;&lt;P&gt;There is probably only one bit missing - the script_progress dialog shows me that there are actually two LOADs for that table, the forst with approx. 20k lines, the second with just 3k lines - but after the reload has finished, I can see that the table still has those 20k lines...&lt;/P&gt;&lt;P&gt;What is missing to complete that operation? I cannot DROP the table so easily since there is no new table...&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ah -. looking closely at your code confirms what our external consultant just told me: All fields in that table must be either the ones to aggregate or they must be in the GROUP BY clause, right?&lt;/P&gt;&lt;P&gt;That is another particular that's not mentioned in the book.&lt;/P&gt;&lt;P&gt;Is there any feedbyck possibility? there should be...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 13:27:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447605#M695132</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-05-10T13:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: Compacting a table so I can join it into my data_model?</title>
      <link>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447606#M695133</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;I made it now - almost.&lt;/P&gt;&lt;P&gt;I had to adapt my code to that general SQL principle, so I used just three fields and included two of them in the GROUP BY clause.&lt;/P&gt;&lt;P&gt;I did that in a RESIDENT load and dropped the original table afterward.&lt;/P&gt;&lt;P&gt;Now my new table has just a few thousand records instead of 20k.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the keyfield is still not unique: For some reason, there are still two records for certain item_numbers - and when I build that new field into my diagram, I don't get any value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DataNibbler&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 14:29:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Compacting-a-table-so-I-can-join-it-into-my-data-model/m-p/447606#M695133</guid>
      <dc:creator>datanibbler</dc:creator>
      <dc:date>2013-05-10T14:29:21Z</dc:date>
    </item>
  </channel>
</rss>

