<?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: Issue with using Max() or FirstSortedValue() to define field in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851277#M298587</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Hey Colin,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;FirstSortedValue is an aggregation function so you have to use with GROUP BY in your script. Could this be an issue?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Apr 2015 16:40:01 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-04-16T16:40:01Z</dc:date>
    <item>
      <title>Issue with using Max() or FirstSortedValue() to define field</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851276#M298586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two tables in my data set, one which has all current data and one the historical values of the same fields, each time an update was made.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the first table I have four fields: &lt;STRONG&gt;Item_Master_ID&lt;/STRONG&gt;, &lt;STRONG&gt;Item_Update_ID&lt;/STRONG&gt;, &lt;STRONG&gt;Item_Colour&lt;/STRONG&gt; and &lt;STRONG&gt;Item_Key.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The historical table contains &lt;STRONG&gt;Item_HistUpdate_ID&lt;/STRONG&gt;, &lt;STRONG&gt;Item_HistColour&lt;/STRONG&gt; and &lt;STRONG&gt;Item_Key&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both tables also have a date field which records when the entry update was made.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, the colour of the item can change with an update (but does not always). When an update occurs, the existing &lt;STRONG&gt;Item_Update_ID&lt;/STRONG&gt; goes into the historical table becomes the latest &lt;STRONG&gt;Item_HistUpdate_ID&lt;/STRONG&gt;. Likewise the corresponding &lt;STRONG&gt;Item_Colour&lt;/STRONG&gt; becomes the latest &lt;STRONG&gt;Item_HistColour&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each Item can have multiple updates recorded as entries in the historical table, all with a unique identifier &lt;STRONG&gt;Item_HistUpdate_ID&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The tables are linked on &lt;STRONG&gt;Item_Key&lt;/STRONG&gt;, which is unique for every &lt;STRONG&gt;Item_Master_ID&lt;/STRONG&gt; and the data sources appear as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CurrentTable:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); 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;&lt;STRONG&gt;&lt;STRONG style=": ; font-size: 10pt; font-family: arial,helvetica,sans-serif;"&gt;Item_Key&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;Item_Master_ID&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;Item_Update_ID&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;Item_Colour&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;897865&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;42456&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;341891&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Green&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;04-Apr-2015&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;736211&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;28613&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;398673&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Blue&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;16-Mar-2015&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;378854&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;18762&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;328002&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"&gt;Red&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;SPAN style="font-size: 10pt; font-family: arial,helvetica,sans-serif;"&gt;02-Apr-2015&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;HistoricalTable:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); 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;&lt;STRONG&gt;&lt;STRONG&gt;Item_Key&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;&lt;STRONG&gt;Item_HistUpdate_ID&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;&lt;STRONG&gt;Item_HistColour&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;897865&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;332567&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Green&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;31-Mar-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;897865&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;317832&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Orange&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;18-Mar-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;897865&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;309987&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Orange&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15-Mar-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;736211&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;386512&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Green&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;26-Feb-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;736211&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;367531&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Yellow&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;09-Jan-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;378854&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;311654&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Blue&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;25-Mar-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;378854&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;310892&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Blue&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;21-Mar-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;378854&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;298761&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Black&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;03-Mar-2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;378854&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;257439&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Black&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;21-Feb-2015&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to load a field in the script to display the previous colour of an item (i.e. the latest historical one). By taking the max (Item_HistUpdate_ID) it should provide this, but I have been getting an error when trying to define this in the load script of the Historical table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have also tried to load the following the to create this field, but I believe this FirstSortedValue() function can’t be used like this in the load script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FirstSortedValue(Item_HistColour,-&lt;STRONG&gt; &lt;/STRONG&gt;Item_HistUpdate_ID) AS Last_HistFlag&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are there any suggestions on the best way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also want to identify any entries where an item colour changed to the current one. E.g. For item_Master_ID 42456, it changed two iterations previous to the current one. Is there a lookup function which can be used to do this in the load script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the long question but any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 15:44:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851276#M298586</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-04-16T15:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using Max() or FirstSortedValue() to define field</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851277#M298587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Hey Colin,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;FirstSortedValue is an aggregation function so you have to use with GROUP BY in your script. Could this be an issue?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 16:40:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851277#M298587</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-04-16T16:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using Max() or FirstSortedValue() to define field</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851278#M298588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Boris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's a good point. Would this have to be done in a separate table within the load script and how best should this be structured?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 16:57:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851278#M298588</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-04-16T16:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using Max() or FirstSortedValue() to define field</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851279#M298589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;see my example - the idea is to concatenate current and histoircal data first in one table, assigning MAster ID at the same time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then sort in a script data by Item_id, date descending and use peek function to assign previous color - that's why we need to sort data first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 18:45:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851279#M298589</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-04-16T18:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using Max() or FirstSortedValue() to define field</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851280#M298590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Boris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry the delay in getting back to you. Thank you for the proposed solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data structure has changed since then, but I should be able to apply this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 14:04:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851280#M298590</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-11T14:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with using Max() or FirstSortedValue() to define field</title>
      <link>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851281#M298591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;great, I am glad you found it helpful, good luck with your project!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 14:15:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Issue-with-using-Max-or-FirstSortedValue-to-define-field/m-p/851281#M298591</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-11T14:15:51Z</dc:date>
    </item>
  </channel>
</rss>

