<?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 aggr() function in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Help-with-aggr-function/m-p/249088#M94715</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I find that the aggr function doesn't always work the way I think it will and unfortunately the documentation around this function is limited and only helpful for specific scenarios.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to count firstly the number of people selling an item in 2010 who had previously bought an item.&amp;nbsp; I calculate this using the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;=sum (&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aggr(min( {&amp;lt; RECORD_TYPE={'BUYER'}, SALE_YEAR=&amp;gt;} SALE_START_DATE), CONTACT_ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aggr(min( {&amp;lt; RECORD_TYPE={'SELLER'}, SALE_YEAR={'2010'}&amp;gt;} SALE_START_DATE), CONTACT_ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,1,0))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In English, I am trying to say that if the minimum sale_start_date where a contact_id was a buyer (irrespective of year) is less than the minimum sale_start_date in the sale_year of 2010 where a contact_id was a seller, then give me a 1.&amp;nbsp; Summing these 1/0 flags should give me the number of contact_id's who sold in 2010 and had bought previously (either ealier in 2010 or earlier ever).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not confident that the number it is returning is correct.&amp;nbsp; I can do this in a table with Contact_ID as the dimension and without the aggregation and I can generate the 1/0 flag, so this is the next step in dropping the Contact_ID from the table and aggregating up to a total level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gareth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Oct 2011 11:12:12 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-10-14T11:12:12Z</dc:date>
    <item>
      <title>Help with aggr() function</title>
      <link>https://community.qlik.com/t5/QlikView/Help-with-aggr-function/m-p/249088#M94715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I find that the aggr function doesn't always work the way I think it will and unfortunately the documentation around this function is limited and only helpful for specific scenarios.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to count firstly the number of people selling an item in 2010 who had previously bought an item.&amp;nbsp; I calculate this using the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="sql" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;=sum (&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aggr(min( {&amp;lt; RECORD_TYPE={'BUYER'}, SALE_YEAR=&amp;gt;} SALE_START_DATE), CONTACT_ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; aggr(min( {&amp;lt; RECORD_TYPE={'SELLER'}, SALE_YEAR={'2010'}&amp;gt;} SALE_START_DATE), CONTACT_ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,1,0))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In English, I am trying to say that if the minimum sale_start_date where a contact_id was a buyer (irrespective of year) is less than the minimum sale_start_date in the sale_year of 2010 where a contact_id was a seller, then give me a 1.&amp;nbsp; Summing these 1/0 flags should give me the number of contact_id's who sold in 2010 and had bought previously (either ealier in 2010 or earlier ever).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not confident that the number it is returning is correct.&amp;nbsp; I can do this in a table with Contact_ID as the dimension and without the aggregation and I can generate the 1/0 flag, so this is the next step in dropping the Contact_ID from the table and aggregating up to a total level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gareth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 11:12:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Help-with-aggr-function/m-p/249088#M94715</guid>
      <dc:creator />
      <dc:date>2011-10-14T11:12:12Z</dc:date>
    </item>
  </channel>
</rss>

