<?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 Help with a set analysis statement that allows me to identify a max value and then pull data related to that value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Help-with-a-set-analysis-statement-that-allows-me-to-identify-a/m-p/1116825#M520885</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;History table (records related to a claim):　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helv;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;HistoryID | ClaimID | EventDate | Segment | ClaimOpen　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;----------+---------+------------+---------+----------　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 | 1 | 2016-01-01 | Level 3 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 | 1 | 2016-01-02 | Level 3 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3 | 1 | 2016-01-03 | Level 1 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4 | 1 | 2016-02-15 | Level 1 | N　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5 | 2 | 2016-01-01 | Level 0 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6 | 2 | 2016-01-01 | Level 1 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7 | 2 | 2016-01-02 | Level 3 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Claim table:　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helv;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ClaimID | Adjuster　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--------+------------　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 | Smith, Joe　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 | Jane, Mary　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The script will set an event date range, where 　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helv;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;let vEndDate = "2016-01-31";　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I need to be able to count all ClaimIDs where the Max EventDate in the History table, relative to the date 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;range (vEndDate), is on a row where the Segment = Level 2, Level 3 or Level 4 &lt;STRONG&gt;and &lt;/STRONG&gt;a ClaimOpen value = Y. 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I may have duplicate EventDates, I need to interrogate the HistoryID, since the largest HistoryID value 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;corresponds to the most recent EventDate, per ClaimID. Once I have identified that HistoryID, I then only 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;want to include/count the rows that meet the above 2　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;conditions. 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the expression I built:　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helv;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Count({　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;EventDate={"&amp;lt;=$(=vEndDate)"}　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;,Segment={'Level 2','Level 3','Level 4'}　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;,HistoryID={"=aggr(max(HistoryID), ClaimID)"}　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;,ClaimOpen={"Y"}　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;} distinct ClaimID)　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;For this example, I need the expression to identify rows 3 and 7 as the rows with the max history for 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;their respective claim IDs, but only count row 7 since that is the only max row that meets the Segment and ClaimOpen conditions.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Jun 2016 01:37:47 GMT</pubDate>
    <dc:creator />
    <dc:date>2016-06-27T01:37:47Z</dc:date>
    <item>
      <title>Help with a set analysis statement that allows me to identify a max value and then pull data related to that value</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-a-set-analysis-statement-that-allows-me-to-identify-a/m-p/1116825#M520885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;History table (records related to a claim):　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helv;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;HistoryID | ClaimID | EventDate | Segment | ClaimOpen　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;----------+---------+------------+---------+----------　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 | 1 | 2016-01-01 | Level 3 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 | 1 | 2016-01-02 | Level 3 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3 | 1 | 2016-01-03 | Level 1 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4 | 1 | 2016-02-15 | Level 1 | N　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5 | 2 | 2016-01-01 | Level 0 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6 | 2 | 2016-01-01 | Level 1 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;7 | 2 | 2016-01-02 | Level 3 | Y　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Claim table:　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helv;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;ClaimID | Adjuster　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--------+------------　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 | Smith, Joe　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 | Jane, Mary　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The script will set an event date range, where 　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helv;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;let vEndDate = "2016-01-31";　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I need to be able to count all ClaimIDs where the Max EventDate in the History table, relative to the date 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;range (vEndDate), is on a row where the Segment = Level 2, Level 3 or Level 4 &lt;STRONG&gt;and &lt;/STRONG&gt;a ClaimOpen value = Y. 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I may have duplicate EventDates, I need to interrogate the HistoryID, since the largest HistoryID value 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;corresponds to the most recent EventDate, per ClaimID. Once I have identified that HistoryID, I then only 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;want to include/count the rows that meet the above 2　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;conditions. 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the expression I built:　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Helv;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Count({　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;EventDate={"&amp;lt;=$(=vEndDate)"}　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;,Segment={'Level 2','Level 3','Level 4'}　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;,HistoryID={"=aggr(max(HistoryID), ClaimID)"}　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;,ClaimOpen={"Y"}　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;} distinct ClaimID)　&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;For this example, I need the expression to identify rows 3 and 7 as the rows with the max history for 　&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;their respective claim IDs, but only count row 7 since that is the only max row that meets the Segment and ClaimOpen conditions.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jun 2016 01:37:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-a-set-analysis-statement-that-allows-me-to-identify-a/m-p/1116825#M520885</guid>
      <dc:creator />
      <dc:date>2016-06-27T01:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a set analysis statement that allows me to identify a max value and then pull data related to that value</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-a-set-analysis-statement-that-allows-me-to-identify-a/m-p/1116826#M520886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I have solved part of the problem - I have figured out how to bring back the max historyID per claimID using FirstSortedValue.&amp;nbsp; Even if the historyID's share the same date it is bringing back the max HistoryID value.&amp;nbsp; Here is the syntax and it is working:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;=Max(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;firstsortedvalue&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;HistoryID&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;, -&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;EventDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;), &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ClaimID&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;So now what I have to do is, for the max HistoryID value, count it if the HistorySegment and HistoryClaimOpen values meet my parameters.&amp;nbsp; I am trying to use a set analysis expression to set the HistoryID to the max, but Qlik doesn't like it.&amp;nbsp; Can I do this?&amp;nbsp; And if so, how should it be wrttien?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Count&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;STRONG style=": ; color: #ff0000; font-size: 8pt;"&gt;(&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;{&lt;BR /&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;HistoryID&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={Max(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;firstsortedvalue&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;HistoryID&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;, -&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;EventDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;), &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ClaimNumber&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;))}&lt;BR /&gt; ,HistorySegment={'Level 2', 'Level 3', &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;"Level 4'}&lt;BR /&gt; ,HistoryClaimOpen = {'Y'}&amp;gt;&lt;BR /&gt; }distinct ClaimID) &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jun 2016 16:42:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-a-set-analysis-statement-that-allows-me-to-identify-a/m-p/1116826#M520886</guid>
      <dc:creator />
      <dc:date>2016-06-27T16:42:16Z</dc:date>
    </item>
  </channel>
</rss>

