<?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 as KPI Stat in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696812#M1076847</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the fastest way is change the control from Pivot table to straight table and use "Sum" as the total Mode for that field.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Jul 2014 10:28:41 GMT</pubDate>
    <dc:creator />
    <dc:date>2014-07-17T10:28:41Z</dc:date>
    <item>
      <title>Weighted Average as KPI Stat</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696811#M1076846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking for some help on weighted averages. I have looked through the other examples on this site but cannot find one to match my query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a list of companies with a market value held, target price and current price. What I want to do is to be able to show a one item key performance indicator that shows the weighted average total return for all stocks selected by the user.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached the sample data in excel as well as my attempt to weighted average in the attached QVW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sample excel table shown below - the columns 'DB field' are in the excel file and are known. The 'calculation fields' are used to calculate the weighted average return.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 668px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl66" colspan="4" height="16" width="383"&gt;&lt;STRONG&gt;DB FIELDS&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD class="xl66" colspan="3" width="206"&gt;&lt;STRONG&gt;CALCULATION FIELDS&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl65" height="16"&gt;DESCRIPTION&lt;/TD&gt;&lt;TD class="xl65" style="text-align: center;"&gt;AUM&lt;/TD&gt;&lt;TD class="xl65"&gt;Target&lt;/TD&gt;&lt;TD class="xl65"&gt;Current&lt;/TD&gt;&lt;TD class="xl67"&gt;Expd TR&lt;/TD&gt;&lt;TD class="xl67"&gt;Weight&lt;/TD&gt;&lt;TD class="xl67"&gt;Weighted TR&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="16"&gt;COMPANY A&lt;/TD&gt;&lt;TD class="xl63"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 392,674,467&lt;/TD&gt;&lt;TD align="right"&gt;18.4&lt;/TD&gt;&lt;TD align="right"&gt;16.37&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;12.4%&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;60.3%&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;7.5%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="16"&gt;COMPANY B&lt;/TD&gt;&lt;TD class="xl63"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 258,514,789&lt;/TD&gt;&lt;TD align="right"&gt;2.2&lt;/TD&gt;&lt;TD align="right"&gt;1.82&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;20.9%&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;39.7%&lt;/TD&gt;&lt;TD align="right" class="xl64"&gt;8.3%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl68"&gt;W AVG TR&lt;/TD&gt;&lt;TD align="right" class="xl69"&gt;15.8%&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been able to get to the point of calculating the market value weighted total return in a pivot table (listed as 'W AVG EXPD RTN' in the QVW) but I cannot work out how to&lt;/P&gt;&lt;P&gt;a) Sum this value within the pivot (partial sum gives a blank)&lt;/P&gt;&lt;P&gt;b) have the calculation bundled up into a separate field (e.g. Weighted Average Total Return text box in the attached QVW).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Really would appreciate help on this one - I have been struggling with this one for some time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 10:16:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696811#M1076846</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-07-17T10:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average as KPI Stat</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696812#M1076847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the fastest way is change the control from Pivot table to straight table and use "Sum" as the total Mode for that field.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 10:28:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696812#M1076847</guid>
      <dc:creator />
      <dc:date>2014-07-17T10:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average as KPI Stat</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696813#M1076848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you simply want to&amp;nbsp; Sum your W AVG EXPT RTN, try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(aggr(Sum((TARGET - CURRENT)/CURRENT)* SUM(MARKET_VALUE)/SUM(TOTAL MARKET_VALUE)), DESCRIPTION))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 10:32:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696813#M1076848</guid>
      <dc:creator>marcus_malinow</dc:creator>
      <dc:date>2014-07-17T10:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average as KPI Stat</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696814#M1076849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks - but even as straight table I still get a '-' in the total column. When you say 'use sum as total mode' - what does this mean exactly, I cannot see this as an option, or do you mean creation of a custom label that is SUM(w avg column)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also this would not answer my key issue to have a separate cell that consolidates the results&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 10:34:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696814#M1076849</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-07-17T10:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average as KPI Stat</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696815#M1076850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Boom! That works a treat!! I cant thank you enough &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;Clearly I need to brush up on my understanding of the aggr function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 10:38:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696815#M1076850</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-07-17T10:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average as KPI Stat</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696816#M1076851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Marcus - could I ask for your assistance again here: as I have come to implement this fully I have hit a snag which seems to be breaking the formula, I cannot see why.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the following formula in a table to get the correct weighted total return. The difference here is the change to the denominator - I needed to exclude the market value of holdings where there is no target price as this would otherwise skew the number when aggregated. The result is correct in the column is it in but as before there is no sum (as no aggr is being used at this stage presumably).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;((Target - Current)/Current)*(SUM(MKT_VAL)/(SUM( TOTAL {$&amp;lt;Target = {'*'}-{''}&amp;gt;} MKT_VAL))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Implementing the same formula that worked earlier combined with the above I am getting crazy results&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NUM(sum(aggr(Sum((Target - Current)/Current)*(SUM(MKT_VAL)/SUM( TOTAL {$&amp;lt;Target = {'*'}-{''}&amp;gt;} MKT_VAL)), DESCRIPTION)),'#.#%')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" style="width: 697px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class="xl65" height="17" width="77"&gt;DESCRIPTION&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="50"&gt;TARGET&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="40"&gt;PRICE&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="88"&gt;TOTAL RETURN&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="76"&gt;MKT VALUE&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="98"&gt;% All&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="98"&gt;Weighted Avg&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="98"&gt;Aggr Formula&lt;/TD&gt;&lt;TD class="xl65" style="border-left: none;" width="72"&gt;Multiple Diff&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl66" height="17" style="border-top: none;"&gt; &lt;/TD&gt;&lt;TD class="xl67" style="border-top: none;"&gt; &lt;/TD&gt;&lt;TD class="xl67" style="border-top: none;"&gt; &lt;/TD&gt;&lt;TD class="xl68" style="border-top: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl69" style="border-top: none; border-left: none;"&gt;1,722,421,335&lt;/TD&gt;&lt;TD class="xl70" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD class="xl71" style="border-top: none; border-left: none;"&gt; &lt;/TD&gt;&lt;TD align="right" class="xl72" style="border-top: none; border-left: none;"&gt;-27.86%&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;COMPANY A&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top: none; border-left: none;"&gt;120.00&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top: none; border-left: none;"&gt;108.15&lt;/TD&gt;&lt;TD align="right" class="xl75" style="border-top: none; border-left: none;"&gt;10.957%&lt;/TD&gt;&lt;TD align="right" class="xl76" style="border-top: none; border-left: none;"&gt;1,181,628,840&lt;/TD&gt;&lt;TD align="right" class="xl77" style="border-top: none; border-left: none;"&gt;68.6%&lt;/TD&gt;&lt;TD align="right" class="xl78" style="border-top: none; border-left: none;"&gt;7.5168%&lt;/TD&gt;&lt;TD align="right" class="xl79" style="border-top: none; border-left: none;"&gt;60.13%&lt;/TD&gt;&lt;TD class="xl80"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8.00 &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;COMPANY B&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top: none; border-left: none;"&gt;18.40&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top: none; border-left: none;"&gt;16.37&lt;/TD&gt;&lt;TD align="right" class="xl75" style="border-top: none; border-left: none;"&gt;12.401%&lt;/TD&gt;&lt;TD align="right" class="xl76" style="border-top: none; border-left: none;"&gt;392,674,467&lt;/TD&gt;&lt;TD align="right" class="xl77" style="border-top: none; border-left: none;"&gt;22.8%&lt;/TD&gt;&lt;TD align="right" class="xl78" style="border-top: none; border-left: none;"&gt;2.8271%&lt;/TD&gt;&lt;TD align="right" class="xl79" style="border-top: none; border-left: none;"&gt;8.48%&lt;/TD&gt;&lt;TD class="xl80"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.00 &lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD class="xl73" height="17" style="border-top: none;"&gt;COMPANY C&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top: none; border-left: none;"&gt;96.00&lt;/TD&gt;&lt;TD align="right" class="xl74" style="border-top: none; border-left: none;"&gt;483.20&lt;/TD&gt;&lt;TD align="right" class="xl75" style="border-top: none; border-left: none;"&gt;-80.132%&lt;/TD&gt;&lt;TD align="right" class="xl76" style="border-top: none; border-left: none;"&gt;148,118,029&lt;/TD&gt;&lt;TD align="right" class="xl77" style="border-top: none; border-left: none;"&gt;8.6%&lt;/TD&gt;&lt;TD align="right" class="xl78" style="border-top: none; border-left: none;"&gt;-6.8909%&lt;/TD&gt;&lt;TD align="right" class="xl79" style="border-top: none; border-left: none;"&gt;-96.47%&lt;/TD&gt;&lt;TD class="xl80"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14.00 &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Strangely, the 'wrong' result (total of -27%) is based on exact multiples of the correct weighted average on a line by line basis. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you see what I am doing wrong here? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jul 2014 15:18:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696816#M1076851</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-07-17T15:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Weighted Average as KPI Stat</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696817#M1076852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can't see anything obviously wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps adding a flag in the load to indicate a NULL Target value might help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alternatively if you upload another copy of your QVW someone might be able to help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jul 2014 08:41:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-as-KPI-Stat/m-p/696817#M1076852</guid>
      <dc:creator>marcus_malinow</dc:creator>
      <dc:date>2014-07-18T08:41:36Z</dc:date>
    </item>
  </channel>
</rss>

