<?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 Weighted Average Formula in Formatted Report in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Weighted-Average-Formula-in-Formatted-Report/m-p/177576#M45124</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a requirement to calculate a weighted average on a YTD basis within a formatted report.&lt;/P&gt;&lt;P&gt;Please see below.&lt;/P&gt;&lt;P&gt;I am trying to create a weighted average for the USD/AUD Rate, weighting the Rate with the 'Total Cost (Cash + Non Cash)'. So in essence, relating two lines of the formatted report to each other for a formula.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="error loading image" class="jive-image error-loading-image" src="https://community.qlik.com/legacyfs/online/-2770_sourceID:2770" /&gt;&lt;/P&gt;&lt;P&gt;I have done this in the past with simple divisions and multiplications by flagging the amount and using a SET.&lt;/P&gt;&lt;P&gt;I could create a formula flag and change the formula to as follows&lt;/P&gt;&lt;P&gt;If(FLFormulaType = 'WA',&lt;BR /&gt; Sum ({$&amp;lt;FLExpNum = {'1'}&amp;gt;} TranTotal) /&lt;BR /&gt; Sum ({$&amp;lt;FLExpNum = {'2'}&amp;gt;} TranTotal)&lt;/P&gt;&lt;P&gt;But in order to create a weighted average, you need to encase the multiplication formula with Sum(). The reason for this is it isn't the TOTAL FLExpNum1 * TOTAL ExpNum2, it is ExpNum1 * ExpNum2 on a month to month basis. I.E.&lt;/P&gt;&lt;P&gt;Sum(TranTotal1 * TranTotal2).&lt;/P&gt;&lt;P&gt;The difficulty with this is they can not be flagged in this manner, and i am dealing with a transactional table which hasn't been grouped into months making it even more difficult.&lt;/P&gt;&lt;P&gt;Can I use Exp() or agg() here?&lt;/P&gt;&lt;P&gt;I'm really at a loss what to do from here so any help would be great!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Nov 2010 10:45:51 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-11-09T10:45:51Z</dc:date>
    <item>
      <title>Weighted Average Formula in Formatted Report</title>
      <link>https://community.qlik.com/t5/QlikView/Weighted-Average-Formula-in-Formatted-Report/m-p/177576#M45124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a requirement to calculate a weighted average on a YTD basis within a formatted report.&lt;/P&gt;&lt;P&gt;Please see below.&lt;/P&gt;&lt;P&gt;I am trying to create a weighted average for the USD/AUD Rate, weighting the Rate with the 'Total Cost (Cash + Non Cash)'. So in essence, relating two lines of the formatted report to each other for a formula.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="error loading image" class="jive-image error-loading-image" src="https://community.qlik.com/legacyfs/online/-2770_sourceID:2770" /&gt;&lt;/P&gt;&lt;P&gt;I have done this in the past with simple divisions and multiplications by flagging the amount and using a SET.&lt;/P&gt;&lt;P&gt;I could create a formula flag and change the formula to as follows&lt;/P&gt;&lt;P&gt;If(FLFormulaType = 'WA',&lt;BR /&gt; Sum ({$&amp;lt;FLExpNum = {'1'}&amp;gt;} TranTotal) /&lt;BR /&gt; Sum ({$&amp;lt;FLExpNum = {'2'}&amp;gt;} TranTotal)&lt;/P&gt;&lt;P&gt;But in order to create a weighted average, you need to encase the multiplication formula with Sum(). The reason for this is it isn't the TOTAL FLExpNum1 * TOTAL ExpNum2, it is ExpNum1 * ExpNum2 on a month to month basis. I.E.&lt;/P&gt;&lt;P&gt;Sum(TranTotal1 * TranTotal2).&lt;/P&gt;&lt;P&gt;The difficulty with this is they can not be flagged in this manner, and i am dealing with a transactional table which hasn't been grouped into months making it even more difficult.&lt;/P&gt;&lt;P&gt;Can I use Exp() or agg() here?&lt;/P&gt;&lt;P&gt;I'm really at a loss what to do from here so any help would be great!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2010 10:45:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weighted-Average-Formula-in-Formatted-Report/m-p/177576#M45124</guid>
      <dc:creator />
      <dc:date>2010-11-09T10:45:51Z</dc:date>
    </item>
  </channel>
</rss>

