<?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 Aggr function not working in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730372#M261622</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 am trying to get the number of customer that didn't make purchases in the current selected month but did buy the previous month, I am using set analysis to get the previous month as the user might not select it. See my expression below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(aggr (if(sum({&amp;lt;YYYYMM={$(vPrevMonthMaxYM)},Year=,Month=&amp;gt;} Sales)&amp;lt;&amp;gt;0 and sum(if(YYYYMM=vMaxYM, Sales,0)) = 0,1,0), [Store Number], [Account Code]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following dimensions in my chart: region and store.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not working, it is returning less count than I expect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked my logic by looking at [Store Number] and [Account Code] as dimensions and if(sum({&amp;lt;YYYYMM={$(vPrevMonthMaxYM)},Year=,Month=&amp;gt;} Sales)&amp;lt;&amp;gt;0 and sum(if(YYYYMM=vMaxYM, Sales,0)) = 0,1,0) as an expression in a table chart and it is giving me what I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the same aggr&amp;nbsp; function to count the number of customers who did not make purchases in the 6 months prior to the selected (max) month but have started buying in the select (max) month, and that is working 100s. And I use the same ... somewhere else and is working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Oct 2014 07:46:11 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-10-30T07:46:11Z</dc:date>
    <item>
      <title>Aggr function not working</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730372#M261622</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 am trying to get the number of customer that didn't make purchases in the current selected month but did buy the previous month, I am using set analysis to get the previous month as the user might not select it. See my expression below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(aggr (if(sum({&amp;lt;YYYYMM={$(vPrevMonthMaxYM)},Year=,Month=&amp;gt;} Sales)&amp;lt;&amp;gt;0 and sum(if(YYYYMM=vMaxYM, Sales,0)) = 0,1,0), [Store Number], [Account Code]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following dimensions in my chart: region and store.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not working, it is returning less count than I expect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked my logic by looking at [Store Number] and [Account Code] as dimensions and if(sum({&amp;lt;YYYYMM={$(vPrevMonthMaxYM)},Year=,Month=&amp;gt;} Sales)&amp;lt;&amp;gt;0 and sum(if(YYYYMM=vMaxYM, Sales,0)) = 0,1,0) as an expression in a table chart and it is giving me what I want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the same aggr&amp;nbsp; function to count the number of customers who did not make purchases in the 6 months prior to the selected (max) month but have started buying in the select (max) month, and that is working 100s. And I use the same ... somewhere else and is working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 07:46:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730372#M261622</guid>
      <dc:creator />
      <dc:date>2014-10-30T07:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730373#M261623</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could it be possible of a customer buying in two stores 6 months ago, and just in one of them during the last month?&lt;/P&gt;&lt;P&gt;then you could get different results in both expressions explained.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 07:54:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730373#M261623</guid>
      <dc:creator>diego_alegre_nu</dc:creator>
      <dc:date>2014-10-30T07:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730374#M261624</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A customer has an account per store, if he/she has two accounts in different stores we count him/her as two customers, different accounts. This is a chain liquor business on the redistribution/delivery side - selling and delivering&amp;nbsp; to business i.e. hotels, restaurants, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The one that is not working is where I am looking at those customers/accounts who bought last month but not this month. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The other ones are working fine and are not related.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 08:29:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730374#M261624</guid>
      <dc:creator />
      <dc:date>2014-10-30T08:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730375#M261625</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you post the sample application with output needed so that t will be more clearer?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 08:43:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730375#M261625</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2014-10-30T08:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730376#M261626</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;If the customer did not buy in the current month, then I assume there are no records in the data for that store / account / month, so in&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;sum(if(YYYYMM=vMaxYM, Sales,0)) = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the sum evaluates to Missing and your condition will always return false. You could try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alt(sum(if(YYYYMM=vMaxYM, Sales,0)), 0) = 0&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;Alt(sum({&amp;lt;YYYYMM={$(vMaxYM)}&amp;gt;} Sales), 0) = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that does not work, try switching the condition around:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.... Alt(sum({&amp;lt;YYYYMM={$(vMaxYM)}&amp;gt;} Sales), 0) &amp;gt; 0, 0, 1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 08:45:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730376#M261626</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2014-10-30T08:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730377#M261627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you are correct Jonathan, there are no records in the data for the month selected except for zero sales for commission accounts that are hard-coded in the load script (don't ask - long story - previous developer), these are the only accounts that I am getting in my results, &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I am getting the same results with all your suggestions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I must note though if I include the previous month in my selection I do get the correct results but this is not ideal - I need a fix for one month selection.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 12:30:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730377#M261627</guid>
      <dc:creator />
      <dc:date>2014-10-30T12:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function not working</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730378#M261628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ideal solution for this is in the load script. You could create dummy records, although these can mess with counts. Another approach is for the load script to create a flag table, with period, account, store and a flag to indicate whether there are records or not. This should be populated for all possible combinations, and the flag will be set if there are any real transactions against those dimensions and the other combinations get a zero to indicate no transactions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then instead of summing sales in the front end, you can get the flag value, which will always exist, if done correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 13:06:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-not-working/m-p/730378#M261628</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2014-10-30T13:06:23Z</dc:date>
    </item>
  </channel>
</rss>

