<?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: Aggr function on avg in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922530#M319528</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thinking about it, whilst you have Level and Geography as dimensions, the aggr function is doing absolutely nothing, you can just do avg(Sales) to get the average.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aggr functions are only useful if you intend to use the output as a dimension, or if you need to put another expression around it, for example:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum(aggr(avg(Sales),Geography,Level))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will give you the total of the averages by those dimensions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Jul 2015 19:54:11 GMT</pubDate>
    <dc:creator>stevedark</dc:creator>
    <dc:date>2015-07-30T19:54:11Z</dc:date>
    <item>
      <title>Aggr function on avg</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922527#M319525</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 need average of&amp;nbsp; sales at 'geography' and '&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;level' and want to compare ID sales with that average. I have tried aggr function but it's giving null for some values. Please help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Navdeep&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2015 19:04:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922527#M319525</guid>
      <dc:creator />
      <dc:date>2015-07-30T19:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function on avg</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922528#M319526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Navdeep,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You either need to remove the ID as a dimension from the table, or add ID as a parameter to the AGGR function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How you have it at the moment where Level and Geography have two IDs; the correct average is being put on one of the rows and the null value is being shown on the other.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2015 19:34:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922528#M319526</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2015-07-30T19:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function on avg</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922529#M319527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;change your avg expression as&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;avg(total &amp;lt;Geography,Level&amp;gt;Sales)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please see the attached&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2015 19:48:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922529#M319527</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2015-07-30T19:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function on avg</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922530#M319528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thinking about it, whilst you have Level and Geography as dimensions, the aggr function is doing absolutely nothing, you can just do avg(Sales) to get the average.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aggr functions are only useful if you intend to use the output as a dimension, or if you need to put another expression around it, for example:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum(aggr(avg(Sales),Geography,Level))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will give you the total of the averages by those dimensions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jul 2015 19:54:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922530#M319528</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2015-07-30T19:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function on avg</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922531#M319529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kush,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems perfect I have some set conditions also, how to include those in this expression and if possible please briefly explain the &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;avg(total &amp;lt;Geography,Level&amp;gt;Sales) expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Navdeep&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 05:30:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922531#M319529</guid>
      <dc:creator />
      <dc:date>2015-07-31T05:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function on avg</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922532#M319530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, yes I understand your point, m always little confused about the functionality of aggr(). &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 05:37:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922532#M319530</guid>
      <dc:creator />
      <dc:date>2015-07-31T05:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function on avg</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922533#M319531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;avg(total &amp;lt;Geography,Level&amp;gt;Sales) - It will return the avg of&amp;nbsp; Sales within selection of each Geography and level.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If you have set expression then please use the solution suggested by Steve.Because due to total qualifier Set expression will not give you accurate results&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 06:21:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922533#M319531</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2015-07-31T06:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Aggr function on avg</title>
      <link>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922534#M319532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The way to think of AGGR is allowing you to create a temporary table and then do further calculations over it.&amp;nbsp; So, say you wanted the sum of values for field A and B in a table, but as the total you wanted to show the Average of all those rows; you would simply create a table with A and B as dimensions, have your expression as &lt;STRONG&gt;sum(Value)&lt;/STRONG&gt; and then change the &lt;STRONG&gt;Total Mode&lt;/STRONG&gt; to &lt;STRONG&gt;average&lt;/STRONG&gt;.&amp;nbsp; All very simple and no AGGR statements involved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, if you wanted to show the average value in a text box or in the caption of a chart, you would not have a table with all the rows in - so you would need to create a virtual table to work over.&amp;nbsp; The expression &lt;STRONG&gt;avg(aggr(sum(Value), A, B)) &lt;/STRONG&gt;will do this for you.&amp;nbsp; Essentially, the table you have in the first example is made in memory, for the average function to work over.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is the basic premise of AGGR, but it can be used in other scenarios also.&amp;nbsp; One that I use quite frequently is when calculating exceptions and having them emailed out by a QlikView alert.&amp;nbsp; So, perhaps where a Customer has gone over their credit limit.&amp;nbsp; I use an AGGR on the CustomerID with an IF statement in, returning Customer Name for those over the limit and NULL for those under.&amp;nbsp; Around the AGGR I put a Concat DISTINCT statement, that then turns this into a list of items.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that clears it up for you?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 07:52:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Aggr-function-on-avg/m-p/922534#M319532</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2015-07-31T07:52:26Z</dc:date>
    </item>
  </channel>
</rss>

