<?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: Standard deviation and weighted average in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Standard-deviation-and-weighted-average/m-p/336783#M494852</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The simplest approach might be to unaggregate the scores again.&amp;nbsp; For instance:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Raw:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD Score as Score2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT Aggregated&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHILE iterno()&amp;lt;=Respondents&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can just use avg(Score2) and stdev(Score2).&amp;nbsp; Even if you have a huge sample size, it's only a single small integer getting duplicated (Edit: well, plus a key field to connect it to your data), so the memory requirements might not be bad.&amp;nbsp; If that is impractical for you, here's a way to calculated the weighted average and the standard deviation without unaggregating:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;weighted average&amp;nbsp;&amp;nbsp; = sum(Score*Respondents)/sum(Respondents)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;standard deviation = sqrt(sum(Respondents*sqr(Score-sum(total Score*Respondents)/sum(total Respondents)))/(sum(Respondents)-1))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may or may not want the final -1 in the standard deviation.&amp;nbsp; It's required to duplicate what QlikView does, and Wikipedia indicates that this is used when you have a sample from a population.&amp;nbsp; If you have ALL responses, then it may be appropriate to remove it.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;See attached.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Mar 2012 01:50:22 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2012-03-06T01:50:22Z</dc:date>
    <item>
      <title>Standard deviation and weighted average</title>
      <link>https://community.qlik.com/t5/QlikView/Standard-deviation-and-weighted-average/m-p/336782#M494851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am analysing aggregated survey results using Qlikview. The results&amp;nbsp; of the survey are on a scale 1-5, so for example I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Score 1 - 12 respondents&lt;/P&gt;&lt;P&gt;Score 2 - 23 respondents&lt;/P&gt;&lt;P&gt;Score 3 - 45 respondents&lt;/P&gt;&lt;P&gt;Score 4 - 120 respondents&lt;/P&gt;&lt;P&gt;Score 5 - 35 respondents&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each rating score is a separate dimension in the data source and is aggregated data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking to calculate two statistics:&lt;/P&gt;&lt;P&gt;1) the weighted average score&lt;/P&gt;&lt;P&gt;2) the standard deviation of the mean&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that to calculate the weighted average in excel it would be (1 x 12) + (2 x 23) + (3 x 45) +(4 x 120) + (5 x 35) /&amp;nbsp;&amp;nbsp; 235&amp;nbsp; (number of respondents) = 3.6&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From this I need to calculate the standard deviation of the mean. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I am having trouble expressing this in qlikview. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Mar 2012 19:46:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Standard-deviation-and-weighted-average/m-p/336782#M494851</guid>
      <dc:creator />
      <dc:date>2012-03-05T19:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Standard deviation and weighted average</title>
      <link>https://community.qlik.com/t5/QlikView/Standard-deviation-and-weighted-average/m-p/336783#M494852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The simplest approach might be to unaggregate the scores again.&amp;nbsp; For instance:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;Raw:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD Score as Score2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;RESIDENT Aggregated&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;WHILE iterno()&amp;lt;=Respondents&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can just use avg(Score2) and stdev(Score2).&amp;nbsp; Even if you have a huge sample size, it's only a single small integer getting duplicated (Edit: well, plus a key field to connect it to your data), so the memory requirements might not be bad.&amp;nbsp; If that is impractical for you, here's a way to calculated the weighted average and the standard deviation without unaggregating:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;weighted average&amp;nbsp;&amp;nbsp; = sum(Score*Respondents)/sum(Respondents)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;standard deviation = sqrt(sum(Respondents*sqr(Score-sum(total Score*Respondents)/sum(total Respondents)))/(sum(Respondents)-1))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may or may not want the final -1 in the standard deviation.&amp;nbsp; It's required to duplicate what QlikView does, and Wikipedia indicates that this is used when you have a sample from a population.&amp;nbsp; If you have ALL responses, then it may be appropriate to remove it.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;See attached.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Mar 2012 01:50:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Standard-deviation-and-weighted-average/m-p/336783#M494852</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2012-03-06T01:50:22Z</dc:date>
    </item>
  </channel>
</rss>

