<?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 in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/AGGR-Function/m-p/236884#M88013</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;Hi,&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;I have a problem that is tying me up in knots and which I think the AGGR function will resolve, but I just can't quite get it to work.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;I want to plot on a chart how a selected store is performing against, stores of a similar type, stores in a similar geographical area and all stores in the estate. So for each date I will show four bars:&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P class="MsoListParagraph" style="text-indent: -18pt; margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1;"&gt;· Actual sales for selected store&lt;/P&gt;&lt;P class="MsoListParagraph" style="text-indent: -18pt; margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1;"&gt;· Average sales for stores in geo area&lt;/P&gt;&lt;P class="MsoListParagraph" style="text-indent: -18pt; margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1;"&gt;· Average sales for stores of similar type&lt;/P&gt;&lt;P class="MsoListParagraph" style="text-indent: -18pt; margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1;"&gt;· Average sales for all stores&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;I believe the expression for the selected store looks like this:&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="text-indent: 36pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;AGGR(SUM({$&amp;lt; StoreName = {"$(=GetFieldSelections(StoreName))"} &amp;gt;} SalesValue ), Date_WkNo)&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;However, what I have for the other three expressions is returning weird results. For example my geographical comparison expression below returns the same result as that above:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-indent: 36pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;AVG(AGGR(SUM({$&amp;lt; StoreGroup = {"$(=MAXSTRING(StoreGroup))"}, StoreName = &amp;gt;} SalesValue), StoreGroup, StoreName, Date_WkNo))&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;The logic behind what I'm trying to do here is to find the group for the selected store and calculate the average total sales, by date, for the stores in that group. My expression for the stores of a similar format is very similar to the group one above but my expression for returning the average sales for all stores is this, which also returns the same result as the others:&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="text-indent: 36pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;AVG(AGGR(SUM({$&amp;lt; StoreName = &amp;gt;} SalesValue ), StoreName, Date_WkNo))&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;Any help in resolving this problem would be appreciated.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;Thanks,&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;Graeme&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Mar 2011 20:07:51 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-03-02T20:07:51Z</dc:date>
    <item>
      <title>AGGR Function</title>
      <link>https://community.qlik.com/t5/QlikView/AGGR-Function/m-p/236884#M88013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;Hi,&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;I have a problem that is tying me up in knots and which I think the AGGR function will resolve, but I just can't quite get it to work.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;I want to plot on a chart how a selected store is performing against, stores of a similar type, stores in a similar geographical area and all stores in the estate. So for each date I will show four bars:&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P class="MsoListParagraph" style="text-indent: -18pt; margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1;"&gt;· Actual sales for selected store&lt;/P&gt;&lt;P class="MsoListParagraph" style="text-indent: -18pt; margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1;"&gt;· Average sales for stores in geo area&lt;/P&gt;&lt;P class="MsoListParagraph" style="text-indent: -18pt; margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1;"&gt;· Average sales for stores of similar type&lt;/P&gt;&lt;P class="MsoListParagraph" style="text-indent: -18pt; margin: 0cm 0cm 0pt 36pt; mso-list: l0 level1 lfo1;"&gt;· Average sales for all stores&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;I believe the expression for the selected store looks like this:&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="text-indent: 36pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;AGGR(SUM({$&amp;lt; StoreName = {"$(=GetFieldSelections(StoreName))"} &amp;gt;} SalesValue ), Date_WkNo)&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;However, what I have for the other three expressions is returning weird results. For example my geographical comparison expression below returns the same result as that above:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-indent: 36pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;AVG(AGGR(SUM({$&amp;lt; StoreGroup = {"$(=MAXSTRING(StoreGroup))"}, StoreName = &amp;gt;} SalesValue), StoreGroup, StoreName, Date_WkNo))&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;The logic behind what I'm trying to do here is to find the group for the selected store and calculate the average total sales, by date, for the stores in that group. My expression for the stores of a similar format is very similar to the group one above but my expression for returning the average sales for all stores is this, which also returns the same result as the others:&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="text-indent: 36pt; margin: 0cm 0cm 0pt; mso-layout-grid-align: none;"&gt;AVG(AGGR(SUM({$&amp;lt; StoreName = &amp;gt;} SalesValue ), StoreName, Date_WkNo))&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;Any help in resolving this problem would be appreciated.&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;Thanks,&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;&lt;/P&gt;&lt;P style="margin: 0cm 0cm 0pt;"&gt;Graeme&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 20:07:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AGGR-Function/m-p/236884#M88013</guid>
      <dc:creator />
      <dc:date>2011-03-02T20:07:51Z</dc:date>
    </item>
    <item>
      <title>AGGR Function</title>
      <link>https://community.qlik.com/t5/QlikView/AGGR-Function/m-p/236885#M88014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there, the issue I found here is that the last aggregation you are using does not contain any set analysis at all, which means that it will remain with the user actual selections, for instance, the following expression should return the result you are looking for:&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;AVG(({$&amp;lt; StoreGroup = {"$(=MAXSTRING(StoreGroup))"}, StoreName = &amp;gt;} AGGR(SUM({$&amp;lt; StoreGroup = {"$(=MAXSTRING(StoreGroup))"}, StoreName = &amp;gt;} SalesValue), StoreGroup, StoreName, Date_WkNo))&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;I think in most cases it will be enough to use:&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;AVG(({$&amp;lt; StoreGroup = {"$(=MAXSTRING(StoreGroup))"}, StoreName = &amp;gt;} SalesValue)&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;However, it will all depend on the dimension you have within the graphic.&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;&lt;/P&gt;&lt;P style="TEXT-INDENT:36pt;MARGIN:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 20:18:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AGGR-Function/m-p/236885#M88014</guid>
      <dc:creator />
      <dc:date>2011-03-02T20:18:35Z</dc:date>
    </item>
    <item>
      <title>AGGR Function</title>
      <link>https://community.qlik.com/t5/QlikView/AGGR-Function/m-p/236886#M88015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ivan,&lt;/P&gt;&lt;P&gt;Thanks for your reply. The problem i've had with&lt;/P&gt;&lt;P style="text-indent:36pt;margin:0cm 0cm 0pt;mso-layout-grid-align:none;"&gt;AVG(({$&amp;lt; StoreGroup = {"$(=MAXSTRING(StoreGroup))"}, StoreName = &amp;gt;} SalesValue)&lt;/P&gt;&lt;P&gt;is that it gives me the average transaction value across the stores whereas I'm after the average of the sum of all transactions for each store. I think that's why I need to use the AGGR function in this case.&lt;/P&gt;&lt;P&gt;That said, your first example has worked a treat so thank you for your help.&lt;/P&gt;&lt;P&gt;AVG(({$&amp;lt; StoreGroup = {"$(=MAXSTRING(StoreGroup))"}, StoreName = &amp;gt;} AGGR(SUM({$&amp;lt; StoreGroup = {"$(=MAXSTRING(StoreGroup))"}, StoreName = &amp;gt;} SalesValue), StoreGroup, StoreName, Date_WkNo))&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Graeme&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Mar 2011 21:29:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/AGGR-Function/m-p/236886#M88015</guid>
      <dc:creator />
      <dc:date>2011-03-02T21:29:27Z</dc:date>
    </item>
  </channel>
</rss>

