<?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, and if statement, plus remove some values in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077060#M640941</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the chart I have a set of products that are generally sold by the Company. That Company is being compared to the entire market that the Company belongs to. If the Product price is LESS then the Average Market price, then you subtract them, to get the potential money that is lost on this company.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you an see, the product, Seats, has no Potential, because the Average Market price is less then the company price.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to find a way to get this formula for the Potential by Market, for each Company in a separate chart, that only has the Companies listed. This means that it does not need to count the Difference of the Company Sales and the Average Market sales, if the Product has no Potential. But everything I have tried, still subtracts the two and gives me the Potential for everything from that Company, and not what I want, only the Products that provide Potential sales.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I need an Aggr() function for the Products but I am not sure how to get them to compare the Company to the Avg of the Market for each Product and then only sum the Products that have Potential.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table in my QV document that is similar to the one below and the Potential expression I have works fine there. The only problem is if I remove the Products, then formula doesn't act right. Here is my formula&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff8000; font-size: 8pt; text-decoration: underline;"&gt;&lt;STRONG style="font-size: 12pt;"&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt;(&lt;SPAN style="color: #0000ff;"&gt;Num&lt;/SPAN&gt;(&lt;STRONG&gt;&lt;EM style=": ; color: #808080;"&gt;$(vAvgSalesForSize)&lt;/EM&gt;&lt;/STRONG&gt;-&lt;STRONG&gt;&lt;EM style=": ; color: #808080;"&gt;$(vAvgSalesForSelectedCompany)&lt;/EM&gt;&lt;/STRONG&gt; )&amp;lt;=0,0,&lt;SPAN style="color: #0000ff;"&gt;Num&lt;/SPAN&gt;(&lt;STRONG&gt;&lt;EM style=": ; color: #808080;"&gt;$(vAvgSalesForSize)&lt;/EM&gt;&lt;/STRONG&gt;-&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;$(&lt;STRONG&gt;&lt;EM style="color: #808080;"&gt;vAvgSalesForSelectedCompany&lt;/EM&gt;&lt;/STRONG&gt;)&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt; ))&lt;/SPAN&gt;&lt;STRONG style=": ; color: #ff8000; text-decoration: underline;"&gt;)&lt;/STRONG&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried to break this down as easily as I could, but if I need to make anything more clear please let me know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For Company ABC&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In Size "Small" Market&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; border-image: none; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Product&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Company ABC Sales&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Avg Small Market Sales&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Potential&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Tires&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$50&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$75&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Windshield&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$100&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$120&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Seats&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$20&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$10&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Total Potential&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$45&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Jan 2016 20:24:24 GMT</pubDate>
    <dc:creator>crystles</dc:creator>
    <dc:date>2016-01-26T20:24:24Z</dc:date>
    <item>
      <title>Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077060#M640941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the chart I have a set of products that are generally sold by the Company. That Company is being compared to the entire market that the Company belongs to. If the Product price is LESS then the Average Market price, then you subtract them, to get the potential money that is lost on this company.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you an see, the product, Seats, has no Potential, because the Average Market price is less then the company price.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to find a way to get this formula for the Potential by Market, for each Company in a separate chart, that only has the Companies listed. This means that it does not need to count the Difference of the Company Sales and the Average Market sales, if the Product has no Potential. But everything I have tried, still subtracts the two and gives me the Potential for everything from that Company, and not what I want, only the Products that provide Potential sales.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe I need an Aggr() function for the Products but I am not sure how to get them to compare the Company to the Avg of the Market for each Product and then only sum the Products that have Potential.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table in my QV document that is similar to the one below and the Potential expression I have works fine there. The only problem is if I remove the Products, then formula doesn't act right. Here is my formula&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff8000; font-size: 8pt; text-decoration: underline;"&gt;&lt;STRONG style="font-size: 12pt;"&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt;"&gt;&lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt;(&lt;SPAN style="color: #0000ff;"&gt;Num&lt;/SPAN&gt;(&lt;STRONG&gt;&lt;EM style=": ; color: #808080;"&gt;$(vAvgSalesForSize)&lt;/EM&gt;&lt;/STRONG&gt;-&lt;STRONG&gt;&lt;EM style=": ; color: #808080;"&gt;$(vAvgSalesForSelectedCompany)&lt;/EM&gt;&lt;/STRONG&gt; )&amp;lt;=0,0,&lt;SPAN style="color: #0000ff;"&gt;Num&lt;/SPAN&gt;(&lt;STRONG&gt;&lt;EM style=": ; color: #808080;"&gt;$(vAvgSalesForSize)&lt;/EM&gt;&lt;/STRONG&gt;-&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style=": ; color: #808080; font-size: 12pt;"&gt;$(&lt;STRONG&gt;&lt;EM style="color: #808080;"&gt;vAvgSalesForSelectedCompany&lt;/EM&gt;&lt;/STRONG&gt;)&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt; ))&lt;/SPAN&gt;&lt;STRONG style=": ; color: #ff8000; text-decoration: underline;"&gt;)&lt;/STRONG&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried to break this down as easily as I could, but if I need to make anything more clear please let me know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;For Company ABC&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;In Size "Small" Market&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; border-image: none; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Product&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Company ABC Sales&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Avg Small Market Sales&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Potential&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Tires&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$50&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$75&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Windshield&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$100&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$120&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Seats&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$20&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$10&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;Total Potential&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;$45&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 20:24:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077060#M640941</guid>
      <dc:creator>crystles</dc:creator>
      <dc:date>2016-01-26T20:24:24Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077061#M640942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have not tested it, but may be something along these lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=Sum(Aggr(If(Avg(Sales) &amp;gt; Sum({&amp;lt;Company = {'A'}&amp;gt;} Sales), (&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;Avg(Sales) - Sum({&amp;lt;Company = {'A'}&amp;gt;} Sales)), Product))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:01:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077061#M640942</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-01-26T21:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077062#M640943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SUM(AGGR(&lt;/P&gt;&lt;P&gt;&amp;nbsp; IF(AVG({&amp;lt;Company&amp;gt;}Sales)-SUM(Sales)&amp;gt;0&lt;/P&gt;&lt;P&gt;&amp;nbsp; , AVG({&amp;lt;Company&amp;gt;}Sales)-SUM(Sales)&lt;/P&gt;&lt;P&gt;&amp;nbsp; , 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp; , Product&lt;/P&gt;&lt;P&gt;&amp;nbsp; ))&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;Also see attachment&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:08:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077062#M640943</guid>
      <dc:creator>p_verkooijen</dc:creator>
      <dc:date>2016-01-26T21:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077063#M640944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your formula. I tried inputting my formula that I have in the table already created, with the "Sum(Aggr())" function around it and it does work when I have that company selected. Unfortunatly, when I unselect the Company, it gives me a value of $0, for all the Companies Potential?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is how I made this table to work. So the users can select the company and see their potential. But now I need a summary of all the companies potential.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So like if your formula, I cannot only have one Company "A" selected, I need that in the dimension, per row.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:11:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077063#M640944</guid>
      <dc:creator>crystles</dc:creator>
      <dc:date>2016-01-26T21:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077064#M640945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What if you add Company to the Aggr function?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;=Sum(Aggr(If(Avg(Sales) &amp;gt; Sum({&amp;lt;Company = {'A'}&amp;gt;} Sales), (&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.3333px; 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;Avg(Sales) - Sum({&amp;lt;Company = {'A'}&amp;gt;} Sales)), Product&lt;SPAN style="color: #ff0000;"&gt;, Company&lt;/SPAN&gt;))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:13:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077064#M640945</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-01-26T21:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077065#M640946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I added Company and it immediately made the value $0, even with the Company selected. I thought for sure that would solve the issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:15:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077065#M640946</guid>
      <dc:creator>crystles</dc:creator>
      <dc:date>2016-01-26T21:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077066#M640947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried this, but it only gave me a value of $0 for all Companies.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:17:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077066#M640947</guid>
      <dc:creator>crystles</dc:creator>
      <dc:date>2016-01-26T21:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077067#M640948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure there are no syntax errors? Can you share a sample if possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:19:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077067#M640948</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-01-26T21:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077068#M640949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to change your formula, because of the extra dimension you have to include the TOTAL at the AVG Sales expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM(AGGR(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; IF(AVG(TOTAL &amp;lt;Product&amp;gt; Sales)-SUM(Sales)&amp;gt;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , AVG(TOTAL &amp;lt;Product&amp;gt; Sales)-SUM(Sales)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; , 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; , Product, Company&lt;/P&gt;&lt;P&gt;))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or use the Rangemax instead like &lt;A href="https://community.qlik.com/qlik-users/2286"&gt;rwunderlich&lt;/A&gt; suggested&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM(AGGR(&lt;/P&gt;&lt;P&gt;&amp;nbsp; RangeMax(AVG(TOTAL &amp;lt;Product&amp;gt; Sales)-SUM(Sales), 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp; , Product, Company&lt;/P&gt;&lt;P&gt;&amp;nbsp; ))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:21:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077068#M640949</guid>
      <dc:creator>p_verkooijen</dc:creator>
      <dc:date>2016-01-26T21:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077069#M640950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First, let me suggest that you can simplify by using RangeMax instead of if() to eliminate the negatives. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;RangeMax(Potential, 0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;RangeMax(AvgCompanySales - ThisCompanySales, 0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you want to do the RangeMax over Product, add the Aggr:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sum(Aggr( &lt;/SPAN&gt;&lt;SPAN style="font-size: 13.3333px; font-family: 'courier new', courier;"&gt;RangeMax(AvgCompanySales - ThisCompanySales, 0), Product))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://masterssummit.com" rel="nofollow"&gt;http://masterssummit.com&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://qlikviewcookbook.com" rel="nofollow"&gt;http://qlikviewcookbook.com&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:22:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077069#M640950</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2016-01-26T21:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077070#M640951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is an amazing elegant solution to my original equation. It works perfectly, just like the original, but with much less code involved. Thank you for sharing this approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately it only works if I have the Company selected. I am beginning to think that it is the underlying formulas that are causing the issue, since I wrote it initially, for the User to have to specifically select the Company they wanted to have the formula calculated for.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have broken down all of variables, and I was wondering if anyone can see where the issue might be?&lt;/P&gt;&lt;P&gt;I wanted to make sure all the pieces were included in case the issue is somewhere inside the other pieces of the formula that I had not explained before. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(NOTE, I actually have an extra step where I divide the Sum of Sales by the number of Products, so that is the extra step you are seeing for "Product_Count")&lt;/P&gt;&lt;P&gt;(NOTE 2: I also have to "Annualize" the sum, for the amount of days from the beginning of our fiscal year (96) so I divide the sum by that, then multiply by 365)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;RangeMax&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//$(vAvgSalesForSize) &lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;((&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;( {1&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;MarketSize&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;p&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;MarketSize&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;FY_Year&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;"$(=max([FY_Year]))"&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_AMT&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)/96)*365)&lt;BR /&gt; /&lt;BR /&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({1&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;MarketSize&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;p&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;MarketSize&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)&amp;gt;} &lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Product&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;_Count&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;))&lt;BR /&gt; - &lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-size: 8pt;"&gt;//$(vAvgSalesPerCompany)&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(((&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;FY_Year&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;"$(=max([FY_Year]))"&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_AMT&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;))/96)*365)/&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Product&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;_Count&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)&lt;BR /&gt; , &lt;BR /&gt; &lt;BR /&gt; 0), &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Product&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;))*&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Product&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;_Count&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 21:59:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077070#M640951</guid>
      <dc:creator>crystles</dc:creator>
      <dc:date>2016-01-26T21:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077071#M640952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It would be useful if you could upload a small sample. You can reduce and scramble the data.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/docs/DOC-1290"&gt;Preparing examples for Upload - Reduction and Data Scrambling&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Attached is a simple example, but it would be useful to have the additional fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jan 2016 22:19:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077071#M640952</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2016-01-26T22:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077072#M640953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I will try to load an example later today. But I did find something interesting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I broke the formula up, between the AvgSalesForCompany and AvgSalesForMarket. When the Company is selected, the two numbers are different, and when subtracted, give me the correct answer. But when the Company is not selected and it is showing all the Companies in the list, the two numbers are the exact same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;These numbers are actual rounded values from a selection of one of the Companies to give you a better idea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EXAMPLE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Basic Formula:&lt;/STRONG&gt; (AvgSalesForCompany)&amp;nbsp; -&amp;nbsp; (AvgSalesForMarket)&amp;nbsp; =&amp;nbsp;&amp;nbsp; Potential&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;With Company Selected&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;AvgSalesForCompany = 1,300,000&lt;/P&gt;&lt;P&gt;AvgSalesForMarket = 800,000&lt;/P&gt;&lt;P&gt;Potential = 70,000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;WithOUT Company Selected&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;AvgSalesForCompany = 43,000&lt;/P&gt;&lt;P&gt;AvgSalesForMarket = 43,000&lt;/P&gt;&lt;P&gt;Potential = 0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jan 2016 14:37:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077072#M640953</guid>
      <dc:creator>crystles</dc:creator>
      <dc:date>2016-01-27T14:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function, and if statement, plus remove some values</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077073#M640954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;OK, I did figure out a round about way of creating this formula, though not in the original way I had wanted to.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I had to create a pivot table and add the Products as a dimension.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Then I created AvgForMarketSize field with this formula:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff8000; font-size: 8pt; text-decoration: underline;"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;INVC_FY_Year&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;"$(=max([INVC_FY_Year]))"&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;}&amp;gt;}&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Aggr&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;BR /&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;INVC_FY_Year&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;"$(=max([INVC_FY_Year]))"&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;}&amp;gt;}&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Total&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;BR /&gt; &amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;DealerMarketSize&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CC_L1_Group&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;SHIP_ORDER_AMT&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;), &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;DealerMarketSize&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CUSTOMER_NAME&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CC_L1_Group&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;))&lt;BR /&gt; /96)*365&lt;/SPAN&gt;&lt;STRONG style=": ; color: #ff8000; font-size: 8pt; text-decoration: underline;"&gt;)&lt;/STRONG&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt; /&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;Total&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; {&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;DealerMarketSize&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={'Small'}&amp;gt;} &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;VIO_Count&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;That gave me the average I needed for the Market size and then I just placed that and the Sum for the individual customer into a formula like I had before and it gave me the correct output for the Potential. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The only problem now is, with the Pivot table, it only works when the Products are showing (broken out) in the pivot table. I still need to find a way for it to apply the formula only to the Potential values and sum them up. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thank you for everyones help!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jan 2016 17:23:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-and-if-statement-plus-remove-some-values/m-p/1077073#M640954</guid>
      <dc:creator>crystles</dc:creator>
      <dc:date>2016-01-28T17:23:19Z</dc:date>
    </item>
  </channel>
</rss>

