<?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: Re: Count state from last occurence in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612391#M478974</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp; Miroslav&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'd missed an extra dimension in the aggr second option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the result should be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=-&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&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;max&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;total&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;project&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)= &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;project&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;state&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You say in your example that result should be fully = 3 but partially = 1&lt;/P&gt;&lt;P&gt;however all the projects seem to be complete? Project 144670's status on the latest date is complete.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've used a firstsortedvalue() function in the example to return the latest state for each project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know what you think,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Feb 2014 09:57:52 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-02-21T09:57:52Z</dc:date>
    <item>
      <title>Count state from last occurence</title>
      <link>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612387#M478970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Community &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I need to count projects depending on theirs states, but problem is, that state of projects is changing over time and I want to count always last occurence. I tried this, but it doesn't work for me: &lt;STRONG&gt;count(aggr(max(rep_date),project_id))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Data look like that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;project_id, date, state&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;111, 1.1.2014, A&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;111, 5.1.2014, B&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;222, 2.1.2014, C&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;222, 3.2.2014, B&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;&lt;STRONG&gt;333, 3.1.2014, C&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And result I want is:&lt;/P&gt;&lt;P&gt;count:&lt;/P&gt;&lt;P&gt;B = 2&lt;/P&gt;&lt;P&gt;C = 1&lt;/P&gt;&lt;P&gt;(state A from project 111 and state C from project 222 are not last occurence...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you help me please?&lt;/P&gt;&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 11:49:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612387#M478970</guid>
      <dc:creator />
      <dc:date>2014-02-20T11:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Count state from last occurence</title>
      <link>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612388#M478971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You may use the FirstSortedValue() function to get the last state and then count the state. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table1:&lt;/P&gt;&lt;P&gt;LOAD * Inline [&lt;/P&gt;&lt;P&gt;project_id, date, state&lt;/P&gt;&lt;P&gt;111, 1.1.2014, A&lt;/P&gt;&lt;P&gt;111, 5.1.2014, B&lt;/P&gt;&lt;P&gt;222, 2.1.2014, C&lt;/P&gt;&lt;P&gt;222, 3.2.2014, B&lt;/P&gt;&lt;P&gt;333, 3.1.2014, C&lt;/P&gt;&lt;P&gt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table2:&lt;/P&gt;&lt;P&gt;LOAD project_id, FirstSortedValue(state,-date(Date#(date,'D.M.YYYY'))) as Last_state&lt;/P&gt;&lt;P&gt;Resident Table1&lt;/P&gt;&lt;P&gt;Group By project_id;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 12:08:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612388#M478971</guid>
      <dc:creator>nagaiank</dc:creator>
      <dc:date>2014-02-20T12:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Count state from last occurence</title>
      <link>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612389#M478972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miroslav&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the application (not script) try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;=-&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&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;max&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;total&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;project_id&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)=&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;project_id&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;state&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You were nearly there with the aggr, but what you need to do is include a total in the aggr to return the max(date) for each project ID&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if this works for you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 13:16:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612389#M478972</guid>
      <dc:creator />
      <dc:date>2014-02-20T13:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Count state from last occurence</title>
      <link>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612390#M478973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well...I'm still not sure, what is wrong, so here is example I made from some data. I described problem in text object in this file:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 09:06:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612390#M478973</guid>
      <dc:creator />
      <dc:date>2014-02-21T09:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Count state from last occurence</title>
      <link>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612391#M478974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp; Miroslav&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'd missed an extra dimension in the aggr second option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the result should be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=-&lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&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;max&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;total&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;project&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)= &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;project&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;state&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;date&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You say in your example that result should be fully = 3 but partially = 1&lt;/P&gt;&lt;P&gt;however all the projects seem to be complete? Project 144670's status on the latest date is complete.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've used a firstsortedvalue() function in the example to return the latest state for each project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know what you think,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 09:57:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612391#M478974</guid>
      <dc:creator />
      <dc:date>2014-02-21T09:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Count state from last occurence</title>
      <link>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612392#M478975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, THANK YOU, your solution works exactelly like I wanted to &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And you're right, all projects are finally fully completed, my mistake.&lt;/P&gt;&lt;P&gt;Thanks again and wish you great weekend &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 12:03:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-state-from-last-occurence/m-p/612392#M478975</guid>
      <dc:creator />
      <dc:date>2014-02-21T12:03:00Z</dc:date>
    </item>
  </channel>
</rss>

