<?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: Problem with AGGR - show correct answer only while filtering data in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605099#M444650</link>
    <description>&lt;P&gt;It comes down to the fact that what are you checking your condition against? In order to use set analysis, you will need to create it, but if you are okay to use Aggr with if statement, you can avoid creating these additional fields and do it directly on the front end, But Aggr with if will give you inferior performance.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jul 2019 11:27:08 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2019-07-23T11:27:08Z</dc:date>
    <item>
      <title>Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1604343#M444591</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have an issue with AGGR function in a specific case.&lt;/P&gt;&lt;P&gt;Please refer the following inline table:&lt;/P&gt;&lt;P&gt;Sales:&lt;BR /&gt;load * inline [&lt;BR /&gt;Date, Customer, Product_Code, Amount, Grade&lt;BR /&gt;01/01/2019, A, XA, 10, 5&lt;BR /&gt;01/01/2019, A, XA, -10, 6&lt;BR /&gt;01/01/2019, A, PA, 12, 5&lt;BR /&gt;01/01/2019, A, BC, 8, 5&lt;BR /&gt;01/01/2019, B, XA, 8, 5&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;I want to see total amount per customer per date and show for each date and customer its max grade.&lt;BR /&gt;But, while calculating the max grade (per date &amp;amp; customer)&amp;nbsp; I want to refer only amount which is not equal to 0 (Zero) for the same product.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;So in my case, for customer A at 01/01/2019 i expect to see total amount of 20, and max grade of 5 (as the 6 grade is under product "XA", which should be ignored as its total amount is 0).&lt;BR /&gt;&lt;BR /&gt;I added the following AGGR function:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;=max({&amp;lt;Product_Code={"=SUM(Amount)&amp;lt;&amp;gt;0"}&amp;gt;}aggr(NODISTINCT max({&amp;lt;Product_Code={"=SUM(Amount)&amp;lt;&amp;gt;0"}&amp;gt;}Grade),Date,Customer))&lt;/P&gt;&lt;P&gt;This function will give the correct result ONLY if I filter the data on customer A.&amp;nbsp;&lt;BR /&gt;If the data is not filtered, the grade which will be shown is 6 (which is not what I plan to see...).&lt;BR /&gt;&lt;BR /&gt;Am I missing something? Any ideas?&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Before filtering data. Incorrect Grade" style="width: 715px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/15759iB57911E48315C66B/image-size/large?v=v2&amp;amp;px=999" role="button" title="AGGR1.png" alt="Before filtering data. Incorrect Grade" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Before filtering data. Incorrect Grade&lt;/span&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Data filtrered by Customer A. Correct Grade" style="width: 638px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/15760iEDEF8CCD15271253/image-size/large?v=v2&amp;amp;px=999" role="button" title="AGGR2.png" alt="Data filtrered by Customer A. Correct Grade" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Data filtrered by Customer A. Correct Grade&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jul 2019 07:53:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1604343#M444591</guid>
      <dc:creator>Tomer_St</dc:creator>
      <dc:date>2019-07-21T07:53:26Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1604637#M444611</link>
      <description>&lt;P&gt;Create a new field combining Customer and Product_Code like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sales:
LOAD *,
	 Customer&amp;amp;Product_Code as Customer_Product_Code_Key;
LOAD * INLINE [
    Date, Customer, Product_Code, Amount, Grade
    01/01/2019, A, XA, 10, 5
    01/01/2019, A, XA, -10, 6
    01/01/2019, A, PA, 12, 5
    01/01/2019, A, BC, 8, 5
    01/01/2019, B, XA, 8, 5
];&lt;/LI-CODE&gt;&lt;P&gt;and then use this expression&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Max({&amp;lt;Customer_Product_Code_Key = {"=Sum(Amount) &amp;lt;&amp;gt; 0"}&amp;gt;} Grade)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 Jul 2019 13:08:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1604637#M444611</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-07-22T13:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605015#M444640</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Thanks a lot for your reply!&lt;BR /&gt;This solution is indeed gives the correct grade&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Though,&amp;nbsp; I have more dimensions in my real table (like "Promotion_Code", "Department" etc).&lt;BR /&gt;Do I need to add a key for all combination of Customer and dimension or is there any simpler way to achiave the required result?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Sales:&lt;BR /&gt;LOAD *,&lt;BR /&gt;Customer&amp;amp;Product_Code as Customer_Product_Code_Key,&lt;BR /&gt;Customer&amp;amp;Promotion_Code as Customer_Promotion_Code_Key;&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;Date, Customer, Product_Code, Promotion_Code, Amount, Grade&lt;BR /&gt;01/01/2019, A, XA, AA, 10, 5&lt;BR /&gt;01/01/2019, A, XE, AA, -10, 6&lt;BR /&gt;01/01/2019, A, PA, AC, 12, 5&lt;BR /&gt;01/01/2019, A, BC, AC, 8, 5&lt;BR /&gt;01/01/2019, B, XA, AV, 8, 5&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 09:09:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605015#M444640</guid>
      <dc:creator>Tomer_St</dc:creator>
      <dc:date>2019-07-23T09:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605099#M444650</link>
      <description>&lt;P&gt;It comes down to the fact that what are you checking your condition against? In order to use set analysis, you will need to create it, but if you are okay to use Aggr with if statement, you can avoid creating these additional fields and do it directly on the front end, But Aggr with if will give you inferior performance.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 11:27:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605099#M444650</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-07-23T11:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605219#M444663</link>
      <description>&lt;P&gt;I prefer to use AGGR as I need the calculation of the "grade" to be changed according to users selections (department etc.)&lt;BR /&gt;But when I use the AGGR as mentioned in my first post I get wrong result, unless I choose specific customer.&lt;/P&gt;&lt;P&gt;Should I add IF statement inside the AGGR function for each case of dimension?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jul 2019 14:07:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605219#M444663</guid>
      <dc:creator>Tomer_St</dc:creator>
      <dc:date>2019-07-23T14:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605262#M444668</link>
      <description>&lt;P&gt;Aggr will look like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Max(Aggr(If(Sum(Amount) &amp;lt;&amp;gt; 0, Grade), Customer, Product_Code))&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 23 Jul 2019 15:45:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605262#M444668</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-07-23T15:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605929#M444727</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Thanks a lot for your reply.&lt;BR /&gt;This AGGR function will work in this case, thanks!&lt;/P&gt;&lt;P&gt;But, in my real data there are more dimnsions and I cannot make the AGGR function to work in a similar data like mine.&lt;BR /&gt;Can you please have a look in the below inline and AGGR function and advise what should be revised in order to make it work also with several dimensions?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;load * inline [&lt;BR /&gt;Date, Customer, Product_Code, Promotion_Code, Updating_Divsion, Amount, Grade&lt;BR /&gt;01/01/2019, A, XB, AB, SERVICE, 10, 5&lt;BR /&gt;01/01/2019, A, XA, AB, SALES, -10, 6&lt;BR /&gt;01/01/2019, A, PA, LD, SERVICE, 12, 5&lt;BR /&gt;01/01/2019, A, BG, AD, SALES, 8, 6&lt;BR /&gt;01/01/2019, A, BC, AA, SALES, -8, 6&lt;BR /&gt;02/01/2019, A, BC, AA, SERVICE, 8, 5&lt;BR /&gt;01/01/2019, B, BC, AB, SALES, 8, 5&lt;BR /&gt;02/01/2019, B, FT, AB, SALES, 8, 5&lt;BR /&gt;];&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The AGGR function:&lt;BR /&gt;=Max(Aggr(If(Sum(Amount) &amp;lt;&amp;gt; 0, Grade), Date, Customer, Product_Code, Promotion_Code, Updating_Divsion))&lt;BR /&gt;&lt;BR /&gt;This function will split the Grade for the same customer and date according to other dimensions (promotion_code, product_code, updated_division) and will not give only one max Grade which should be 5 in Customer A, 01/01/2019.&lt;/P&gt;&lt;P&gt;(All 6 grades should be ignored in this case as their amount per dimension - updated_division in one case and Promotion_Code in the other, are 0).&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 05:33:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1605929#M444727</guid>
      <dc:creator>Tomer_St</dc:creator>
      <dc:date>2019-07-25T05:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1606063#M444735</link>
      <description>&lt;P&gt;I guess the question is... what exactly is your expected output based on the sample below and why do you want that?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 11:33:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1606063#M444735</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-07-25T11:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1606730#M444792</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I have data of sales and refunds (amount) with lots of dimension, like division, product, product type, sale type etc.&lt;BR /&gt;Each saling division has grade, according to its importancy. This grade is permanent per division.&lt;/P&gt;&lt;P&gt;If a high division grade made the amount change the user is not concerned about lower division.&lt;BR /&gt;&lt;BR /&gt;The request in the bottom line is to point the division with the higest grade which made the sale or the refund per customer per day.&lt;BR /&gt;But, a&amp;nbsp;division should be ignored in case of total 0 amount.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Also, the user should be able to make dimension selection in the dashboard and the result should be changed accordingly.&lt;BR /&gt;&lt;BR /&gt;For example, for customer A in my last inline code:&lt;BR /&gt;If division "SALES" (which has grade 6, the highest division grade) made the sale, but the total amout is 0 (-10$ for product XA and +10$ for product XB and also -8$ and +8$ under same division "SALES") - in this case the result should be a lower division (in my inline load its division "SERVICE", with grade 5).&lt;BR /&gt;&lt;BR /&gt;For the same case, if the user make a selection of "excluded product XA", the result should be grade 6 (division "SALES") as its total amount&amp;nbsp; without product XA is -10$ and "SALES" is the highest division which made a sales (or refund in this case) which is not 0.&lt;BR /&gt;&lt;BR /&gt;I understand its not so simple and sorry if my explanation is not clear enough...&amp;nbsp;&lt;BR /&gt;Though, I hope it will be sufficiant enough in order for you to help me get the correct formula which will give the right results &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jul 2019 07:05:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1606730#M444792</guid>
      <dc:creator>Tomer_St</dc:creator>
      <dc:date>2019-07-28T07:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1612616#M445257</link>
      <description>&lt;P&gt;Unfortunately, I don't understand this. Would you may be able to give another shot if this has not already been resolved&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2019 18:46:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1612616#M445257</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2019-08-14T18:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AGGR - show correct answer only while filtering data</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1699065#M451108</link>
      <description>&lt;P&gt;the first question is how to make the SUM of DATA (expression) only DATA in front of the MAX (on a dimension) ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 May 2020 11:44:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-AGGR-show-correct-answer-only-while-filtering-data/m-p/1699065#M451108</guid>
      <dc:creator>zarmoton</dc:creator>
      <dc:date>2020-05-05T11:44:01Z</dc:date>
    </item>
  </channel>
</rss>

