<?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: Weekly Average Problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251431#M496740</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since the amount of Fridays in a given month is static, I think it would be best to add the number of Fridays per Month in the data model, maybe along these lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calendar:&lt;/P&gt;&lt;P&gt;LOAD *&lt;/P&gt;&lt;P&gt;,day(Date) as DayOfMonth&lt;/P&gt;&lt;P&gt;,weekday(Date) as Weekday&lt;/P&gt;&lt;P&gt;,Date(monthstart(Date),'YYYY-MMM') as Month&lt;/P&gt;&lt;P&gt;,if(WeekDay(Date)=4,Date) as FridayDate&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt; date(makedate(2011,1,1)+recno()-1) as Date&lt;/P&gt;&lt;P&gt;AUTOGENERATE 365&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fridays:&lt;/P&gt;&lt;P&gt;LOAD Month&lt;/P&gt;&lt;P&gt;,count(FridayDate) as NumFridays&lt;/P&gt;&lt;P&gt; Resident Calendar group by Month;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then your expression could maybe look like:&lt;/P&gt;&lt;P&gt;=count(distinct SaleId) / sum(NumFridays)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: simplified Fridays table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Jan 2012 23:54:01 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2012-01-04T23:54:01Z</dc:date>
    <item>
      <title>Weekly Average Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251428#M496737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am trying to get an &lt;STRONG&gt;average of sales per week &lt;/STRONG&gt;for each person.&amp;nbsp; My dimension is Name.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is that if I filter for December 2011 and Bob only had sales for 2 out of the 4 weeks in December then the formula only uses those 2 weeks he had data for.&amp;nbsp; I want the expression to take his total sales for the month of the December and provide me a weekly average regardless how many weeks he actually submitted a sale during the month of December.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be greatly appreciated! Thanks!&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;count&lt;/SPAN&gt;(&lt;SPAN style="color: #0000ff;"&gt;distinct&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;SaleId&lt;/SPAN&gt;))/&lt;SPAN style="color: #0000ff;"&gt;count&lt;/SPAN&gt;(&lt;SPAN style="color: #0000ff;"&gt;distinct&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;Friday&lt;/SPAN&gt;) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 16:34:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251428#M496737</guid>
      <dc:creator />
      <dc:date>2012-01-04T16:34:34Z</dc:date>
    </item>
    <item>
      <title>Weekly Average Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251429#M496738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If any of the persons worked in each week of the month, you could try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;count&lt;/SPAN&gt;(&lt;SPAN style="color: #0000ff;"&gt;distinct&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;SaleId&lt;/SPAN&gt;))/&lt;SPAN style="color: #0000ff;"&gt;count&lt;/SPAN&gt;(&lt;STRONG&gt;total &lt;/STRONG&gt;&lt;SPAN style="color: #0000ff;"&gt;distinct&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;Friday&lt;/SPAN&gt;) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Probably not the best / most performant way of doing it, so maybe we want to calculate the amount of weeks differently, is amount of Fridays your "official" definition?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 16:44:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251429#M496738</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-01-04T16:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Weekly Average Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251430#M496739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, it is.  Friday is the official definition of my business week.  Friday-Thursday.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 16:47:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251430#M496739</guid>
      <dc:creator />
      <dc:date>2012-01-04T16:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Weekly Average Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251431#M496740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since the amount of Fridays in a given month is static, I think it would be best to add the number of Fridays per Month in the data model, maybe along these lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Calendar:&lt;/P&gt;&lt;P&gt;LOAD *&lt;/P&gt;&lt;P&gt;,day(Date) as DayOfMonth&lt;/P&gt;&lt;P&gt;,weekday(Date) as Weekday&lt;/P&gt;&lt;P&gt;,Date(monthstart(Date),'YYYY-MMM') as Month&lt;/P&gt;&lt;P&gt;,if(WeekDay(Date)=4,Date) as FridayDate&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt; date(makedate(2011,1,1)+recno()-1) as Date&lt;/P&gt;&lt;P&gt;AUTOGENERATE 365&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fridays:&lt;/P&gt;&lt;P&gt;LOAD Month&lt;/P&gt;&lt;P&gt;,count(FridayDate) as NumFridays&lt;/P&gt;&lt;P&gt; Resident Calendar group by Month;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then your expression could maybe look like:&lt;/P&gt;&lt;P&gt;=count(distinct SaleId) / sum(NumFridays)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: simplified Fridays table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 23:54:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251431#M496740</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-01-04T23:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Weekly Average Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251432#M496741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more thought:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Even though your business weeks start on Fridays, it may be worth considering calculating the amount of weeks in a Month not based on Fridays.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, look at April 2011, we get 5 Fridays / business weeks with 21 working days (assuming Mon-Fri).&lt;/P&gt;&lt;P&gt;For May 2011, we get only 4 Fridays, but with 22 working days. Even if you count all days of a month as working days, you will get 5 weeks / 30 days compared to 4 weeks / 31 days, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And all Months show either 4 or 5 Fridays, that means you divide your monthly sales either by 4 or 5, that is 25% difference, not taking into account that most month show 21 / 22 working days, which is a much smaller variation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will of course also affect your comparison of average weekly Sales.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you might want to consider something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD only(Month) as Month&lt;/P&gt;&lt;P&gt;,NetWorkDays(Month,MonthEnd(Month)) as NumWorkDays&lt;/P&gt;&lt;P&gt;,NetWorkDays(Month,MonthEnd(Month)) / 5 as NumWorkWeeks&lt;/P&gt;&lt;P&gt; Resident Calendar group by Month;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And use sum(NumWorkWeeks) to divide your count(distinct SaleId). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you work all days in a month, it could look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD only(Month) as Month&lt;/P&gt;&lt;P&gt;,day(Monthend(Month)) as NumWorkDays&lt;/P&gt;&lt;P&gt;,day(Monthend(Month)) / 7 as NumWorkWeeks&lt;/P&gt;&lt;P&gt;Resident Calendar group by Month;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jan 2012 12:29:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Weekly-Average-Problem/m-p/251432#M496741</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-01-05T12:29:11Z</dc:date>
    </item>
  </channel>
</rss>

