<?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: Trouble using aggr() for YTD Revenue comparison unless both years are selected in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Trouble-using-aggr-for-YTD-Revenue-comparison-unless-both-years/m-p/642493#M235382</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tony,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand, that for each combination of:&lt;/P&gt;&lt;P&gt;Customer_Name, load_key, SALESPRONAME, PSalesNumber&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you need to calculate expression:&lt;/P&gt;&lt;P&gt;Revenue * PSalesNumRate/100&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i dont know your data model,&amp;nbsp; but understand, that there is more combinations of dimensions used in aggr than rows with Revenue * PSalesNumRate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case you need to use set analysis expression in expression inside aggr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;sum({1}aggr(only(&lt;/P&gt;&lt;P&gt;{&amp;lt;FYear={$(=(vMaxSelectedYear)-1)},FQtr={$(vCurrFQtr)},&lt;/P&gt;&lt;P&gt;ShipDate={"&amp;lt;=$(=addmonths(vCurrDateSelectedYear,-12))"}&amp;gt;} &lt;/P&gt;&lt;P&gt;Revenue * PSalesNumRate/100),Customer_Name, load_key, SALESPRONAME, PSalesNumber))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 May 2014 08:02:21 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-05-22T08:02:21Z</dc:date>
    <item>
      <title>Trouble using aggr() for YTD Revenue comparison unless both years are selected</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-aggr-for-YTD-Revenue-comparison-unless-both-years/m-p/642492#M235381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a chart that shows MTD, QTD and YTD Revenue calculations for the sales group.&amp;nbsp; I use the aggr function because at a customer basis, the split between salespeople can vary even at the shipment (load) level depending on the sales number used. Hence my expression looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&amp;nbsp; sum({&amp;lt;FYear={$(=(vMaxSelectedYear)-1)},FQtr={$(vCurrFQtr)},&lt;/P&gt;&lt;P&gt;ShipDate={"&amp;lt;=$(=addmonths(vCurrDateSelectedYear,-12))"}&amp;gt;} &lt;/P&gt;&lt;P&gt;&amp;nbsp; aggr(&lt;/P&gt;&lt;P&gt;&amp;nbsp; (Revenue * (PSalesNumRate/100))&lt;/P&gt;&lt;P&gt;&amp;nbsp; , Customer_Name, load_key, SALESPRONAME, PSalesNumber&amp;nbsp; ) )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works fine when I either have no FYear selection OR I select both 2014 and 2013, for example.&lt;/P&gt;&lt;P&gt;My vMaxSelectedYear variable gets the max year if none is selected.&lt;/P&gt;&lt;P&gt;The problem is that if I have just one year selected (2014) it gives me zero for 2013 Revenue.&lt;/P&gt;&lt;P&gt;I tried putting a 1 in the Set Analysis but it still gave me zero: "sum({&amp;lt;FYear={&lt;STRONG&gt;1&lt;/STRONG&gt;(=(..."&lt;/P&gt;&lt;P&gt;Curiously for my load count (to which I have not applied the split percentage (PSalesNumRate), it works either way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=Count({&amp;lt;FYear={$(=(vMaxSelectedYear)-1)},FQtr={$(vCurrFQtr)},&lt;/P&gt;&lt;P&gt;ShipDate={"&amp;lt;=$(=addmonths(vCurrDateSelectedYear,-12))"}&amp;gt;} cnt_key)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All I want is for it to work regardless of whether there is one, &amp;gt;1 or no years selected, basing prev year on max year selected (or not selected).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2014 22:33:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-aggr-for-YTD-Revenue-comparison-unless-both-years/m-p/642492#M235381</guid>
      <dc:creator>tschullo</dc:creator>
      <dc:date>2014-05-21T22:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using aggr() for YTD Revenue comparison unless both years are selected</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-aggr-for-YTD-Revenue-comparison-unless-both-years/m-p/642493#M235382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tony,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand, that for each combination of:&lt;/P&gt;&lt;P&gt;Customer_Name, load_key, SALESPRONAME, PSalesNumber&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you need to calculate expression:&lt;/P&gt;&lt;P&gt;Revenue * PSalesNumRate/100&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i dont know your data model,&amp;nbsp; but understand, that there is more combinations of dimensions used in aggr than rows with Revenue * PSalesNumRate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your case you need to use set analysis expression in expression inside aggr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;sum({1}aggr(only(&lt;/P&gt;&lt;P&gt;{&amp;lt;FYear={$(=(vMaxSelectedYear)-1)},FQtr={$(vCurrFQtr)},&lt;/P&gt;&lt;P&gt;ShipDate={"&amp;lt;=$(=addmonths(vCurrDateSelectedYear,-12))"}&amp;gt;} &lt;/P&gt;&lt;P&gt;Revenue * PSalesNumRate/100),Customer_Name, load_key, SALESPRONAME, PSalesNumber))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Darek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 08:02:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-aggr-for-YTD-Revenue-comparison-unless-both-years/m-p/642493#M235382</guid>
      <dc:creator />
      <dc:date>2014-05-22T08:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble using aggr() for YTD Revenue comparison unless both years are selected</title>
      <link>https://community.qlik.com/t5/QlikView/Trouble-using-aggr-for-YTD-Revenue-comparison-unless-both-years/m-p/642494#M235383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the quick response - works like a charm!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 May 2014 19:06:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trouble-using-aggr-for-YTD-Revenue-comparison-unless-both-years/m-p/642494#M235383</guid>
      <dc:creator>tschullo</dc:creator>
      <dc:date>2014-05-22T19:06:56Z</dc:date>
    </item>
  </channel>
</rss>

