<?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 Average over three tables in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370701#M1174559</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello to everybody&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to calculate weighted average values over three table. Unfortunately I didn't suceed, thus I hope to find help here. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simplified explanation of the situation. I have a market research database with three tables.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Persons:&lt;/STRONG&gt; Discribes the sample persons with their attributes&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Articles: &lt;/STRONG&gt;Discribes different newspapers articles&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Ratings:&lt;/STRONG&gt; Is the result table combining Persons and Articles and presenting how persons rated the articles&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For our case the following attributes are relevant&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Persons:&lt;/STRONG&gt; PersonId, Gender&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Articles:&lt;/STRONG&gt; ArticleId, LengthOfArticle&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Ratings:&lt;/STRONG&gt; PersonId, ArticleId, Rating&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my diagramm I try to calculate an &lt;STRONG&gt;average Value of the Ratings - weighted by the LengthOfArticle&lt;/STRONG&gt;. I tried the following formula&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(LenghtOfArticle * Rating) / sum(LengthOfArticle). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The calculated "weighted average" is not right - far too high. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody help me? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;Angy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 27 May 2012 18:07:07 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-05-27T18:07:07Z</dc:date>
    <item>
      <title>Average over three tables</title>
      <link>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370701#M1174559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello to everybody&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to calculate weighted average values over three table. Unfortunately I didn't suceed, thus I hope to find help here. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simplified explanation of the situation. I have a market research database with three tables.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Persons:&lt;/STRONG&gt; Discribes the sample persons with their attributes&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Articles: &lt;/STRONG&gt;Discribes different newspapers articles&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Ratings:&lt;/STRONG&gt; Is the result table combining Persons and Articles and presenting how persons rated the articles&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For our case the following attributes are relevant&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Persons:&lt;/STRONG&gt; PersonId, Gender&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Articles:&lt;/STRONG&gt; ArticleId, LengthOfArticle&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Ratings:&lt;/STRONG&gt; PersonId, ArticleId, Rating&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my diagramm I try to calculate an &lt;STRONG&gt;average Value of the Ratings - weighted by the LengthOfArticle&lt;/STRONG&gt;. I tried the following formula&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sum(LenghtOfArticle * Rating) / sum(LengthOfArticle). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The calculated "weighted average" is not right - far too high. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody help me? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;Angy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 May 2012 18:07:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370701#M1174559</guid>
      <dc:creator />
      <dc:date>2012-05-27T18:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: Average over three tables</title>
      <link>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370702#M1174560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just attached a demonstration file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can see the raw data as well as the weighted average in the diagramm. The weighted average (129.78) is higher than the highest single value. The weighted average should be 43.26. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas? Thank you very much for your help...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Untitled-3.jpg" class="jive-image-thumbnail jive-image" onclick="" src="https://community.qlik.com/legacyfs/online/14775_Untitled-3.jpg" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Untitled-5.jpg" class="jive-image-thumbnail jive-image" onclick="" src="https://community.qlik.com/legacyfs/online/14776_Untitled-5.jpg" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 May 2012 19:39:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370702#M1174560</guid>
      <dc:creator />
      <dc:date>2012-05-27T19:39:09Z</dc:date>
    </item>
    <item>
      <title>Average over three tables</title>
      <link>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370703#M1174561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found out what the problem is. Sum(Rating*Length) is calculated in the middle-table (Ratings); Sum(Length) is calculated in the side-table "Tabelle1$-1" (Articles), which has less entities. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The right value is calculated if I use the following expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum(LenghtOfArticle * Rating) / sum(LengthOfArticle * Rating / Rating). &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a better way to calculate the right weighted avg. value? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 May 2012 20:04:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370703#M1174561</guid>
      <dc:creator />
      <dc:date>2012-05-27T20:04:16Z</dc:date>
    </item>
    <item>
      <title>Average over three tables</title>
      <link>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370704#M1174562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Angela86,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you could consider just joining the Length field to your Ratings table, this keeping the measures / facts you need for your calculation in one table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't want to do that, you could use advanced aggregation to achieve the correct result, try something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=sum(aggr(sum(Rating*Length),ArticleId,PersonId))/sum(aggr(sum(Length),ArticleId,PersonId))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yor should be you able to replace the numerator with your original version&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=sum(Rating*Length) / sum(aggr(sum(Length),ArticleId,PersonId))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or your version which is even shorter, but I think the syntax above might express more clearly what you are trying to achieve (evaluating the sums in which contexts).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 May 2012 21:50:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370704#M1174562</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-05-27T21:50:41Z</dc:date>
    </item>
    <item>
      <title>Average over three tables</title>
      <link>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370705#M1174563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stefan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your answer. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am relatively new to QlikView, thus my question. How do I Join the Lenght attribute to my Ratings table? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings&lt;/P&gt;&lt;P&gt;Angela&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 May 2012 22:32:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370705#M1174563</guid>
      <dc:creator />
      <dc:date>2012-05-27T22:32:09Z</dc:date>
    </item>
    <item>
      <title>Average over three tables</title>
      <link>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370706#M1174564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You do a join of tables in the load script, so in your example, you could do it like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Rating:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD PersonId, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArticleId, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rating&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FROM&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;C&gt;&lt;/C&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(biff, embedded labels, table is Tabelle1$);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LEFT JOIN (Rating) LOAD &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArticleId, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Length&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FROM&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;C&gt;&lt;/C&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(biff, embedded labels, table is Tabelle1$);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Persons:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD PersonId, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Gender&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FROM&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;C&gt;&lt;/C&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(biff, embedded labels, table is Persons$);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also labelled the tables (this is always a good idea, some script statements needs a table name, and it's easier to set one yourself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your article table has a lot more information about the specific articles than Length, you could add another load of the articles table, but then without the Length field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Articles:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; ArticleId, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; ArticleName,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp; Manufacturer&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FROM&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;C&gt;&lt;/C&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;(biff, embedded labels, table is Tabelle1$);&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 May 2012 22:54:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Average-over-three-tables/m-p/370706#M1174564</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-05-27T22:54:44Z</dc:date>
    </item>
  </channel>
</rss>

