<?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: Week in Month Calendar Problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Week-in-Month-Calendar-Problem/m-p/913026#M316782</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets see through things.&lt;/P&gt;&lt;P&gt;As I can see WeekYear works something like that:&lt;/P&gt;&lt;P&gt;1. gets middle of the week icluding tmp_Date (thursday)&lt;/P&gt;&lt;P&gt;2. gets year for thursday.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, January, 1, 2011 is Sunday.&lt;/P&gt;&lt;P&gt;1. thursday for this week is December, 31, 2010&lt;/P&gt;&lt;P&gt;2. Year=2010&lt;/P&gt;&lt;P&gt;3. Week also will be calculated for &lt;SPAN style="font-size: 13.3333330154419px;"&gt;December, 31, 2010 = 52&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the same reason we can get WeekYear for December, 30, 2014:&lt;/P&gt;&lt;P&gt;1. &lt;SPAN style="font-size: 13.3333330154419px;"&gt;thursday &lt;SPAN style="font-size: 13.3333330154419px;"&gt;for this week is January, 1, 2015&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;2. Year=2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;3. &lt;SPAN style="font-size: 13.3333330154419px;"&gt;Week also will be calculated for &lt;SPAN style="font-size: 13.3333330154419px;"&gt;January, 1, 2015 = 1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Jul 2015 07:46:56 GMT</pubDate>
    <dc:creator>pokassov</dc:creator>
    <dc:date>2015-07-24T07:46:56Z</dc:date>
    <item>
      <title>Week in Month Calendar Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Week-in-Month-Calendar-Problem/m-p/913024#M316780</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 created the temp_Calendar as following :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LET vMinDate = NUM(Date#('2014-01-01', 'YYYY-MM-DD'));&amp;nbsp;&amp;nbsp;&amp;nbsp; //FY13 and onward&lt;/P&gt;&lt;P&gt;LET vMaxDate = NUM(Date#('2016-12-31', 'YYYY-MM-DD'));&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp_CALENDAR:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date($(vMinDate) + RowNo() -1) AS tmp_Date&lt;/P&gt;&lt;P&gt;AUTOGENERATE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(vMaxDate) - $(vMinDate) + 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note : In Master_Calendar i am Created "[Week in Month] " field as following&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Master_Calendar:&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if(Year(tmp_Date)=WeekYear(tmp_Date), Week(tmp_Date) - Week(MonthStart(tmp_Date)) + 1,&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Week(tmp_Date) - Week(MonthStart(tmp_Date)) + 1) AS [Week in Month]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //week number within a month, 1, 2, 3, 4, 5, 6 &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resident temp_CALENDAR&lt;/P&gt;&lt;P&gt;ORDER BY tmp_Date ASC;&lt;/P&gt;&lt;P&gt;DROP TABLE tmp_CALENDAR;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OUTPUT : (Negative Weeks in Months) Eliminate the negative weeks in "[Week In Month] " Field.&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/servlet/JiveServlet/showImage/2-828504-93714/week in month.png"&gt;&lt;IMG alt="week in month.png" class="jive-image image-1" height="211" src="/legacyfs/online/93857_week in month.png" width="171" /&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Solution 1: &lt;STRONG&gt;if(month(weekend(tmp_Date))= month(tmp_Date),div(day(WeekEnd(tmp_Date)),7),div(day(Weekend(tmp_Date,-&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1)),7)+1)+1 as WeekNumber&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Solution 2: Ceil((Day(tmp_Date)+Week Day(Month Start(tmp_Date)))/7) As [Week in Month]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-size: 12pt;"&gt;But , Can i know the Root cause of the above problem , Because we got same calender in many applications.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Madhu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 06:43:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Week-in-Month-Calendar-Problem/m-p/913024#M316780</guid>
      <dc:creator>madhubabum</dc:creator>
      <dc:date>2015-07-24T06:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Week in Month Calendar Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Week-in-Month-Calendar-Problem/m-p/913025#M316781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Madhu,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your script,&lt;/P&gt;&lt;P&gt;if the year is not equal to WeekYear, &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Week Actual - Week MonthStart +1 , e.g (1 - 49 +1) = -47&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;see the below screen shot.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="93863" alt="Capture.JPG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/93863_Capture.JPG" style="height: 200px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;same for, if Year = WeekYear (1-53+1) = -51&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Capture1JPG.JPG" class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/93864_Capture1JPG.JPG" style="height: 181px; width: 620px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 07:43:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Week-in-Month-Calendar-Problem/m-p/913025#M316781</guid>
      <dc:creator>settu_periasamy</dc:creator>
      <dc:date>2015-07-24T07:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Week in Month Calendar Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Week-in-Month-Calendar-Problem/m-p/913026#M316782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lets see through things.&lt;/P&gt;&lt;P&gt;As I can see WeekYear works something like that:&lt;/P&gt;&lt;P&gt;1. gets middle of the week icluding tmp_Date (thursday)&lt;/P&gt;&lt;P&gt;2. gets year for thursday.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, January, 1, 2011 is Sunday.&lt;/P&gt;&lt;P&gt;1. thursday for this week is December, 31, 2010&lt;/P&gt;&lt;P&gt;2. Year=2010&lt;/P&gt;&lt;P&gt;3. Week also will be calculated for &lt;SPAN style="font-size: 13.3333330154419px;"&gt;December, 31, 2010 = 52&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the same reason we can get WeekYear for December, 30, 2014:&lt;/P&gt;&lt;P&gt;1. &lt;SPAN style="font-size: 13.3333330154419px;"&gt;thursday &lt;SPAN style="font-size: 13.3333330154419px;"&gt;for this week is January, 1, 2015&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;2. Year=2015&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;3. &lt;SPAN style="font-size: 13.3333330154419px;"&gt;Week also will be calculated for &lt;SPAN style="font-size: 13.3333330154419px;"&gt;January, 1, 2015 = 1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 07:46:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Week-in-Month-Calendar-Problem/m-p/913026#M316782</guid>
      <dc:creator>pokassov</dc:creator>
      <dc:date>2015-07-24T07:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Week in Month Calendar Problem</title>
      <link>https://community.qlik.com/t5/QlikView/Week-in-Month-Calendar-Problem/m-p/913027#M316783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try this solution:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if(Week(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;tmp_Date&lt;/SPAN&gt;)&amp;lt;Week(MonthStart(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;tmp_Date&lt;/SPAN&gt;)),Week(MonthStart(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;tmp_Date&lt;/SPAN&gt;)),0)+Week(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;tmp_Date&lt;/SPAN&gt;) - Week(MonthStart(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;tmp_Date&lt;/SPAN&gt;)) + 1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 08:06:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Week-in-Month-Calendar-Problem/m-p/913027#M316783</guid>
      <dc:creator>pokassov</dc:creator>
      <dc:date>2015-07-24T08:06:45Z</dc:date>
    </item>
  </channel>
</rss>

