<?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: Expression sum and average in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Expression-sum-and-average/m-p/664584#M242005</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;For a simple average:&lt;/P&gt;&lt;P&gt;=Avg([number of cars])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I suspect you want the average of the sum by category and area as well:&lt;/P&gt;&lt;P&gt;=Avg(Aggr(Sum([num&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;ber of cars]), Category, Date, state, area))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Sep 2014 15:11:46 GMT</pubDate>
    <dc:creator>jonathandienst</dc:creator>
    <dc:date>2014-09-22T15:11:46Z</dc:date>
    <item>
      <title>Expression sum and average</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-sum-and-average/m-p/664583#M242004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have searched a moment but I have ended up asking for some help &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;I cannot find the proper expression to get what I want. I am pretty sure I have to use the aggr function but well, I haven't found....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table looking like this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Category&amp;nbsp; ; Date&amp;nbsp; ; state ; area ; number of cars&lt;/P&gt;&lt;P&gt;A ;&amp;nbsp; 01/01/2014&amp;nbsp; 05:00 ; repaired ; France ;&amp;nbsp; 98&lt;/P&gt;&lt;P&gt;B ; 06/09/2014 07:00 ; broken ; England ; 12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For each hour of one day, I have for each area, for each state, for each category, the number of cars.&lt;/P&gt;&lt;P&gt;So 24 hours x&amp;nbsp; 3 category x 3 areas x 12 states&amp;nbsp; per day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to show in a graph the average number of cars for each state per day.&amp;nbsp; So in dimensions, I have put Date and State.&amp;nbsp; But I cannot find the right expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I do it in several steps:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First, I would do :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date ; state ; sum(NumberCars)&amp;nbsp;&amp;nbsp;&amp;nbsp; --&amp;gt; so I kind of get rid of the dimensions category and area.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then, I could do AVG&amp;nbsp; (of sum(NumberCars)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope I am clear enough&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any ideas ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2014 15:03:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-sum-and-average/m-p/664583#M242004</guid>
      <dc:creator />
      <dc:date>2014-09-22T15:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Expression sum and average</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-sum-and-average/m-p/664584#M242005</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;For a simple average:&lt;/P&gt;&lt;P&gt;=Avg([number of cars])&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I suspect you want the average of the sum by category and area as well:&lt;/P&gt;&lt;P&gt;=Avg(Aggr(Sum([num&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;ber of cars]), Category, Date, state, area))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2014 15:11:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-sum-and-average/m-p/664584#M242005</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2014-09-22T15:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Expression sum and average</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-sum-and-average/m-p/664585#M242006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Jonathan. This formula works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But now, I want a graph with the week in dimension instead of the date (the day).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the right formula would be something like :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;= AVG(aggr(sum(nb_cars)&lt;STRONG&gt;/7&lt;/STRONG&gt;, Date, Vehicule_Statut, Parc, zone)) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But for the current week, the number of days is not 7 ( eg. it will be 1 if I execute the application on Monday). I don't know how I can handle that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks again &amp;amp; have a good day &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Sep 2014 09:45:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-sum-and-average/m-p/664585#M242006</guid>
      <dc:creator />
      <dc:date>2014-09-23T09:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Expression sum and average</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-sum-and-average/m-p/664586#M242007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could try &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;= Avg(aggr(Avg(nb_cars)&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;, Date, Vehicule_Statut, Parc, zone))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;= Avg(aggr(Sum(nb_cars)/(Today() - WeekStart(Today()))&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;, Date, Vehicule_Statut, Parc, zone))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;If the built in week logic is incorrect, you may have to calculate the date - weekstart(date) during load and store it in your master calendar.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;HTH&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Jonathan&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 06:37:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-sum-and-average/m-p/664586#M242007</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2014-09-25T06:37:03Z</dc:date>
    </item>
  </channel>
</rss>

