<?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: Weighted Average/Sumproduct issue in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159649#M915364</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you try this:&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;&lt;SPAN style="color: #ff0000;"&gt;Sum(Aggr(&lt;/SPAN&gt;(Prices 2016 Expression * Sales 2015 Expression)/ sum(TOTAL Sales 2015 Expression)&lt;SPAN style="color: #ff0000;"&gt;, Market))&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure to list out the complete expressions within the Aggr() function, as it doesn't work with Column Labels (in case you are using that)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 May 2016 15:56:29 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2016-05-27T15:56:29Z</dc:date>
    <item>
      <title>Weighted Average/Sumproduct issue</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159648#M915363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Qlik Community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've stumbled upon a rather annoying problem I can't seem to solve.&lt;/P&gt;&lt;P&gt;Despite finding many questions related to this and trying some solutions I've reached a dead end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am asking for your help concerning &lt;STRONG&gt;weighted averages.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You see, I have a table with Sales: sum(Volume) and Prices: sum(Prices)/sum(sales) as expressions and Market as dimension.&lt;/P&gt;&lt;P&gt;Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 277px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" width="98"&gt;Market&lt;/TD&gt;&lt;TD class="xl70" style="text-align: right;" width="88"&gt;Sales&lt;/TD&gt;&lt;TD class="xl70" style="border-left: medium none; text-align: right;" width="91"&gt;Price&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;A&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;577&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;280&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;B&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;3,879&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;C&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;4,582&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;310&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;D&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;1,242&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;309&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;E&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;5,793&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;223&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;F&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;6,901&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;315&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;G&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;2,420&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;250&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="17" style="border-top: none;"&gt;&lt;STRONG&gt;Total&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top: none; border-left: none;"&gt;&lt;STRONG&gt;25,393&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top: none; border-left: none;"&gt;&lt;STRONG&gt;284&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This table is for 2016, but I need two extra columns for 2015 (Sales + Price 2015). I created them as well in Qlik, no problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is, I need to find the mix effect of &lt;STRONG&gt;one year vs another&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;Now the way I do this in excel is simply sumproduct the prices 2016 * the sales volume 2015, and them divide that by the total sales volume 2015.&lt;/P&gt;&lt;P&gt;I'm not worried about the mix effect by market, but in &lt;STRONG&gt;TOTAL&lt;/STRONG&gt;. For example, if the price is now 284, and with the weight of sales 2015, the price would be... 280, for example. That's a difference of 4 euros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've created the expression&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Prices 2016 =&amp;nbsp;&amp;nbsp; sum(Prices 2016)/sum(sales 2016)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sales 2015 = sum (Sales 2015)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;(Prices 2016 * Sales 2015)/ sum(TOTAL Sales 2015 )&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What QV gives me (BELOW) is the correct expression for each market, of course. But I need the total effect, not the effect by market. However, I need to ponder each market weight for the formula to work. &lt;/P&gt;&lt;P&gt;As you can see, the total remains the same as Price 2016: 283.537 € &lt;/P&gt;&lt;P&gt;The correct value would be 283.957 € if I use sumproduct() in excel. The correct difference is 0.42 €.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I can't really find a solution. This is part of a very important report to be issued every week in the company. Could you help?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Which formula can I use to calculate something like this weighted average?&amp;nbsp; Would I remove the dimension?&lt;/P&gt;&lt;P&gt;What I need is a simple Sumproduct(Sales;Price) / sum(Total Sales 2015).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 428px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" width="98"&gt;Market&lt;/TD&gt;&lt;TD class="xl70" width="88"&gt;Sales 2016&lt;/TD&gt;&lt;TD class="xl70" style="border-left: none;" width="91"&gt;Price 2016&lt;/TD&gt;&lt;TD class="xl70" style="border-left: none;" width="74"&gt;Sales 2015&lt;/TD&gt;&lt;TD class="xl70" style="border-left: none;" width="77"&gt;W Average&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;A&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;577&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;280&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;800&lt;/TD&gt;&lt;TD align="right" class="xl71"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;B&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;3,879&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;300&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;3,812&lt;/TD&gt;&lt;TD align="right" class="xl71"&gt;45&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;C&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;4,582&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;310&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;4,580&lt;/TD&gt;&lt;TD align="right" class="xl71"&gt;55&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;D&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;1,242&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;309&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;1,327&lt;/TD&gt;&lt;TD align="right" class="xl71"&gt;16&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;E&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;5,793&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;223&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;5,632&lt;/TD&gt;&lt;TD align="right" class="xl71"&gt;49&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;F&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;6,901&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;315&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;7,002&lt;/TD&gt;&lt;TD align="right" class="xl71"&gt;86&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt;G&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;2,420&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;250&lt;/TD&gt;&lt;TD align="right" class="xl67" style="border-top: none; border-left: none;"&gt;2,490&lt;/TD&gt;&lt;TD align="right" class="xl71"&gt;24&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68" height="17" style="border-top: none;"&gt;&lt;STRONG style=": ; color: #ff0000;"&gt;Total&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top: none; border-left: none;"&gt;&lt;STRONG&gt;25,393&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top: none; border-left: none;"&gt;&lt;STRONG&gt;284&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top: none; border-left: none;"&gt;&lt;STRONG&gt;25,643&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-left: none;"&gt;&lt;STRONG style="color: #ff0000;"&gt;284&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If this is not the correct method, could you give me any alternatives for calculating such an average?&lt;/P&gt;&lt;P&gt;Please bear in mind I'm really a novice &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mariana.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159648#M915363</guid>
      <dc:creator>mfigueiredo</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average/Sumproduct issue</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159649#M915364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you try this:&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;&lt;SPAN style="color: #ff0000;"&gt;Sum(Aggr(&lt;/SPAN&gt;(Prices 2016 Expression * Sales 2015 Expression)/ sum(TOTAL Sales 2015 Expression)&lt;SPAN style="color: #ff0000;"&gt;, Market))&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make sure to list out the complete expressions within the Aggr() function, as it doesn't work with Column Labels (in case you are using that)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 May 2016 15:56:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159649#M915364</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-05-27T15:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average/Sumproduct issue</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159650#M915365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Sunny,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for helping me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the expression is giving me 0, and I have no idea why?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did try a similar expression with aggr, but I wasn't sure it was correct before and it gave me the same result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any possibility to get a similar sumproduct() result as we do in excel?&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/126147_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mariana.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 May 2016 08:17:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159650#M915365</guid>
      <dc:creator>mfigueiredo</dc:creator>
      <dc:date>2016-05-30T08:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average/Sumproduct issue</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159651#M915366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would you be able to share a sample to help you better here?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 May 2016 09:55:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159651#M915366</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-05-30T09:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average/Sumproduct issue</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159652#M915367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sunny,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, I have one of those "data is confidential" problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can share the expressions, no problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I managed to find the correct number by multiplying the weight in % of the volume 2015 by the price 2016.&lt;/P&gt;&lt;P&gt;If I cummulate that expression, I get the correct value I was talking about above!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the accurate chart. The values in black are real, so I cannot share them. So I multiplied each weight (year) by the price 2016 and got expressions A and B. The last column is the same as B-A but cummulated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is I wanted this fairly automatic in order to get a bar chart and put it on a report.&lt;/P&gt;&lt;P&gt;Seems to me it needs to be manual, nonetheless.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/126187_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mariana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 May 2016 10:38:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159652#M915367</guid>
      <dc:creator>mfigueiredo</dc:creator>
      <dc:date>2016-05-30T10:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average/Sumproduct issue</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159653#M915368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your confidentiality concerns can be handled by looking at this thread:&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;Once again it is difficult to look at screenshots and try to understand what might not be working. A sample will make it much more easier to offer a help. Sample of dummy data with expected output will also be helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 May 2016 11:09:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-Sumproduct-issue/m-p/1159653#M915368</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-05-30T11:09:17Z</dc:date>
    </item>
  </channel>
</rss>

