<?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: Aggr function not working as expected in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50977#M3419</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;let's go throught each part of expression:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;P({&amp;lt;[Store_number]={"1000"}, [YEAR_INVOICE]={"2017"}&amp;gt;}) &lt;/STRONG&gt;- this should return all CLIENT_ID which have record in YEAR_INVOICE=2017 and Store_number=1000&lt;/LI&gt;&lt;LI&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;* - &lt;/STRONG&gt;stands for union&lt;/LI&gt;&lt;LI&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;P({&amp;lt;[INVOICE_DATE]={"=aggr( max({&amp;lt;[INVOICE_DATE]={"&amp;lt;20161123"}&amp;gt;}[INVOICE_DATE]) ,CLIENT_ID))"}&amp;gt;}) &lt;/STRONG&gt;- this should return list of "greatest" invoice date for each CLIENT_ID which was before 20161123&lt;/LI&gt;&lt;LI&gt;1*3 should together return all CLIENT_ID which meet condition that (client has record in YEAR_INVOICE=2017 and Store_number=1000) and (has some record in INVOICE_DATE befor &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;That StoreOpen Day&lt;/SPAN&gt;) &lt;/LI&gt;&lt;LI&gt;Than it just count remaining CLIENT_ID. You are absolutely right, that client will be counted more than one time if has more than one record in given year. If this is not required use DISTINCT in expression&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Is this what you are looking for? Maybe I just don't understand your needs.Maybe it would help if you attach sample data or app.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Apr 2018 12:04:53 GMT</pubDate>
    <dc:creator>DavidŠtorek</dc:creator>
    <dc:date>2018-04-26T12:04:53Z</dc:date>
    <item>
      <title>Aggr function not working as expected</title>
      <link>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50974#M3416</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 need to calculate on the clients that bought something during year 2017 in a specific store, when was the last purchased they did before that store opened 20170101.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was thinking to use an aggregated function to solve that, so for every client_id caculate the last INVOICE_DATE before 20170101 as&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;aggr( &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;max({&amp;lt;[&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;INVOICE_DATE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]={"&amp;lt;&lt;SPAN style="font-size: 13.3333px;"&gt;20170101&lt;/SPAN&gt;"}&amp;gt;}[&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;INVOICE_DATE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;CLIENT_ID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then use FUNCTION count, to count those dates (There should be just one date for every client_id in the aggregated function)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;count({&amp;lt;CLIENT_ID = P({&amp;lt;[Store_number]={"1000"}, [YEAR_INVOICE]={"2017"})*P({&amp;lt;[INVOICE_DATE]={"&amp;lt;20170101"}&amp;gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;, [INVOICE_DATE]={"&amp;lt;20170101"}&amp;gt;} &lt;SPAN style="font-size: 10pt;"&gt;aggr( &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;max({&amp;lt;[&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;INVOICE_DATE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]={"&amp;lt;20161123"}&amp;gt;}[&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;INVOICE_DATE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;CLIENT_ID&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;And put that Function on a graph, in order to count those dates (that are in fact Clients_ID) with dimension INVOICE_YEAR.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;In that way I&amp;nbsp; should see how many of those clients did their previous purchase (&amp;lt; 20170101) in Year 2016, 2015, 2014..... In order to answer if those clients that bought in store 1000&amp;nbsp; were really active&amp;nbsp; or not.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;But that Aggr FUNCTION, is not getting the results I expect, and don´t really know why? The problem is in the Aggregated function, as seems to count Distinct Invoices Date without taking into account client_id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;aggr( &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;max({&amp;lt;[&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;INVOICE_DATE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]={"&amp;lt;&lt;SPAN style="font-size: 13.3333px;"&gt;20170101&lt;/SPAN&gt;"}&amp;gt;}[&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;INVOICE_DATE&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;]) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;CLIENT_ID&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;Any Help?&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;Thanks in advance!!&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2018 16:21:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50974#M3416</guid>
      <dc:creator>luisccmm</dc:creator>
      <dc:date>2018-04-17T16:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working as expected</title>
      <link>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50975#M3417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;this expression &lt;SPAN style="font-size: 10pt; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;STRONG style="font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;aggr( &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG style="font-size: 13.3333px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;max({&amp;lt;[&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;INVOICE_DATE&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;]={"&amp;lt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;20170101&lt;/SPAN&gt;"}&amp;gt;}[&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;INVOICE_DATE&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;]) &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333px; font-family: inherit;"&gt;CLIENT_ID&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;) &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;returns maximal Invoice date by client ID (so you get array of values like 20161212,20161111,20161114...).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: inherit;"&gt;It seems that you are missing some brackets in expression ad there is something more than needed. Try this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;count({&amp;lt;CLIENT_ID = P({&amp;lt;[Store_number]={"1000"}, [YEAR_INVOICE]={"2017"}&amp;gt;})*P({&amp;lt;[INVOICE_DATE]={"=aggr( max({&amp;lt;[INVOICE_DATE]={"&amp;lt;20161123"}&amp;gt;}[INVOICE_DATE]) ,CLIENT_ID))"}&amp;gt;})&amp;gt;}CLIENT_ID)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Hope it helps &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2018 10:56:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50975#M3417</guid>
      <dc:creator>DavidŠtorek</dc:creator>
      <dc:date>2018-04-18T10:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working as expected</title>
      <link>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50976#M3418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks David, but there is some misspealling in your formula, that I don´t really get.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the other hand, I think I more or less understand what you are trying as seems that your looking for the Joint between these two sets:&lt;/P&gt;&lt;P&gt;- Clients ID for that particular shop.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;- Maximum Dates per client ID prior That StoreOpen Day.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Nevertheless, this will probably lead to an ERROR, because if some clientes BOUGHT in different Dates along different YEARS, and some of others dates match the MAX Date of other client (2nd Set) that will count those client more than one time in different years. I am right?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2018 14:19:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50976#M3418</guid>
      <dc:creator>luisccmm</dc:creator>
      <dc:date>2018-04-19T14:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working as expected</title>
      <link>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50977#M3419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;let's go throught each part of expression:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;P({&amp;lt;[Store_number]={"1000"}, [YEAR_INVOICE]={"2017"}&amp;gt;}) &lt;/STRONG&gt;- this should return all CLIENT_ID which have record in YEAR_INVOICE=2017 and Store_number=1000&lt;/LI&gt;&lt;LI&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;* - &lt;/STRONG&gt;stands for union&lt;/LI&gt;&lt;LI&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;P({&amp;lt;[INVOICE_DATE]={"=aggr( max({&amp;lt;[INVOICE_DATE]={"&amp;lt;20161123"}&amp;gt;}[INVOICE_DATE]) ,CLIENT_ID))"}&amp;gt;}) &lt;/STRONG&gt;- this should return list of "greatest" invoice date for each CLIENT_ID which was before 20161123&lt;/LI&gt;&lt;LI&gt;1*3 should together return all CLIENT_ID which meet condition that (client has record in YEAR_INVOICE=2017 and Store_number=1000) and (has some record in INVOICE_DATE befor &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3333px;"&gt;That StoreOpen Day&lt;/SPAN&gt;) &lt;/LI&gt;&lt;LI&gt;Than it just count remaining CLIENT_ID. You are absolutely right, that client will be counted more than one time if has more than one record in given year. If this is not required use DISTINCT in expression&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Is this what you are looking for? Maybe I just don't understand your needs.Maybe it would help if you attach sample data or app.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2018 12:04:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50977#M3419</guid>
      <dc:creator>DavidŠtorek</dc:creator>
      <dc:date>2018-04-26T12:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working as expected</title>
      <link>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50978#M3420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yess it is what I waslooking for, but there is somekind of missepealing, or error on the code, as QLIK SENSE function editor is showing an error when I pass your proposal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;It says "Error in set modifier element function set"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following is how I translated&amp;nbsp; your proposal into local language (spanish)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;count({&amp;lt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ICC = &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;P({&amp;lt;[Centro]={"1243"}, [AÑO_FACTURA]={"2017"}&amp;gt;})&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;*&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;P({&amp;lt;[Fecha Facturación Pedido]={"=aggr( max({&amp;lt;[Fecha Facturación Pedido]={"&amp;lt;20161123"}&amp;gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[Fecha Facturación Pedido]) ,ICC))"}&amp;gt;})&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;DISTINCT ICC)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;But point number 5)&lt;/STRONG&gt; I mean if&amp;nbsp; I use time variable years in a graph with that formula, the client should be counted only once, last purchase date from today regardless of year. So if for example customer XXX1 bought items in year 2014 and 2016, it should only count that customer&amp;nbsp; in year 2016 as it´s the last purchase date. Distinct will only solve problem if that customer bought in different dates from the same year, but not in different years.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2018 13:13:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Aggr-function-not-working-as-expected/m-p/50978#M3420</guid>
      <dc:creator>luisccmm</dc:creator>
      <dc:date>2018-04-26T13:13:13Z</dc:date>
    </item>
  </channel>
</rss>

