<?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: Start week from Monday in the Autocalendar script in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1985635#M81370</link>
    <description>&lt;UL&gt;
&lt;LI&gt;What if you do something like this:&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="script_token"&gt;WeekStart(&lt;/SPAN&gt;&lt;SPAN class="bnf_token"&gt;dateField , -1 , 0&lt;/SPAN&gt;&lt;SPAN class="statement"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="statement"&gt;WeekEnd(dateField , -1 , 0)&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="statement"&gt;OR &lt;STRONG&gt;dayname(WeekEnd(dateField , -1 , 0))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Sep 2022 20:51:08 GMT</pubDate>
    <dc:creator>Vegar</dc:creator>
    <dc:date>2022-09-26T20:51:08Z</dc:date>
    <item>
      <title>Start week from Monday in the Autocalendar script</title>
      <link>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1984994#M81295</link>
      <description>&lt;P&gt;How to get the week start from Monday?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When loading data using the&lt;STRONG&gt; Data Manager,&lt;/STRONG&gt; the script generates an &lt;STRONG&gt;auto-calendar script&lt;/STRONG&gt; where it creates very useful fields such as Week Number, Preivous week tag, etc,. (below is the script sample)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[autoCalendar]: 
  DECLARE FIELD DEFINITION Tagged ('$date')
FIELDS
  Dual(Year($1), YearStart($1)) AS [Year] Tagged ('$axis', '$year'),
  Dual('Q'&amp;amp;Num(Ceil(Num(Month($1))/3)),Num(Ceil(NUM(Month($1))/3),00)) AS [Quarter] Tagged ('$quarter', '$cyclic'),
  Dual(Year($1)&amp;amp;'-Q'&amp;amp;Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [YearQuarter] Tagged ('$yearquarter', '$qualified'),
  Dual('Q'&amp;amp;Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [_YearQuarter] Tagged ('$yearquarter', '$hidden', '$simplified'),
  Month($1) AS [Month] Tagged ('$month', '$cyclic'),
  Dual(Year($1)&amp;amp;'-'&amp;amp;Month($1), monthstart($1)) AS [YearMonth] Tagged ('$axis', '$yearmonth', '$qualified'),
  Dual(Month($1), monthstart($1)) AS [_YearMonth] Tagged ('$axis', '$yearmonth', '$simplified', '$hidden'),
  Dual('W'&amp;amp;Num(Week($1),00), Num(Week($1),00)) AS [Week] Tagged ('$weeknumber', '$cyclic'),
  Date(Floor($1)) AS [Date] Tagged ('$axis', '$date', '$qualified'),
  Date(Floor($1), 'D') AS [_Date] Tagged ('$axis', '$date', '$hidden', '$simplified'),
  If (DayNumberOfYear($1) &amp;lt;= DayNumberOfYear(Today()), 1, 0) AS [InYTD] ,
  Year(Today())-Year($1) AS [YearsAgo] ,
  If (DayNumberOfQuarter($1) &amp;lt;= DayNumberOfQuarter(Today()),1,0) AS [InQTD] ,
  4*Year(Today())+Ceil(Month(Today())/3)-4*Year($1)-Ceil(Month($1)/3) AS [QuartersAgo] ,
  Ceil(Month(Today())/3)-Ceil(Month($1)/3) AS [QuarterRelNo] ,
  If(Day($1)&amp;lt;=Day(Today()),1,0) AS [InMTD] ,
  12*Year(Today())+Month(Today())-12*Year($1)-Month($1) AS [MonthsAgo] ,
  Month(Today())-Month($1) AS [MonthRelNo] ,
  If(WeekDay($1)&amp;lt;=WeekDay(Today()),1,0) AS [InWTD] ,
  (WeekStart(Today())-WeekStart($1))/7 AS [WeeksAgo] ,
  Week(Today())-Week($1) AS [WeekRelNo] ;

DERIVE FIELDS FROM FIELDS [Release Date] USING [autoCalendar] ;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The date field name is &lt;STRONG&gt;[Release Date]&lt;/STRONG&gt; and the above script produces below additional fields&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lwp89_1-1664057846653.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/89823iEBBF28418F1AB2E0/image-size/large?v=v2&amp;amp;px=999" role="button" title="lwp89_1-1664057846653.png" alt="lwp89_1-1664057846653.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;How do I make the Sunday (09-18-2022) included in previous week instead of this week? &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;So the &lt;STRONG&gt;weeksAgo&lt;/STRONG&gt; value for that date&amp;nbsp;&lt;STRONG&gt;(09-18-2022)&lt;/STRONG&gt; becomes 1 instead of 0?&lt;/LI&gt;
&lt;LI&gt;and the &lt;STRONG&gt;weeksAgo&lt;/STRONG&gt; value for that date&amp;nbsp;&lt;STRONG&gt;(09-11-2022)&lt;/STRONG&gt; becomes 2 instead of 1?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;basically a week should be Monday to Sunday not Sunday to Saturday.&lt;/P&gt;
&lt;P&gt;I hope I have explained it well &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Sep 2022 22:20:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1984994#M81295</guid>
      <dc:creator>lwp89</dc:creator>
      <dc:date>2022-09-24T22:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Start week from Monday in the Autocalendar script</title>
      <link>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1984995#M81296</link>
      <description>&lt;P&gt;Default Week start is defined by the system variable&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/sense/August2022/Subsystems/Hub/Content/Sense_Hub/Scripting/NumberInterpretationVariables/FirstWeekDay.htm" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;FirstWeekDay&lt;/SPAN&gt;&lt;/A&gt;. It is also possible to define the week start day in the week function, like this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.qlik.com/en-US/sense/May2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTimeFunctions/week.htm" target="_blank" rel="noopener"&gt;week&lt;/A&gt;(DateField, 0)&lt;/P&gt;</description>
      <pubDate>Sat, 24 Sep 2022 22:58:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1984995#M81296</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2022-09-24T22:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: Start week from Monday in the Autocalendar script</title>
      <link>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1984999#M81298</link>
      <description>&lt;P&gt;Thank&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/25001"&gt;@Vegar&lt;/a&gt;&amp;nbsp;I did set the FirstWeekDay = 0 and its fixed &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2022 01:20:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1984999#M81298</guid>
      <dc:creator>lwp89</dc:creator>
      <dc:date>2022-09-25T01:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Start week from Monday in the Autocalendar script</title>
      <link>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1985624#M81369</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/25001"&gt;@Vegar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just another related question.. Now that I have the correct flag for identifying dates that belongs to previous week.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to find the &lt;STRONG&gt;Week start date&lt;/STRONG&gt; and &lt;STRONG&gt;Week end date&lt;/STRONG&gt; of the previous week? (where &lt;STRONG&gt;ReleaseDate.AutoCalendar.WeekAgo = 1&lt;/STRONG&gt;)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I looked into the &lt;STRONG&gt;WeekStartDate&lt;/STRONG&gt; and &lt;STRONG&gt;WeekEndDate&lt;/STRONG&gt; function but could not figure out how to best use them to find the start and end date of previous week!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 20:30:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1985624#M81369</guid>
      <dc:creator>lwp89</dc:creator>
      <dc:date>2022-09-26T20:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Start week from Monday in the Autocalendar script</title>
      <link>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1985635#M81370</link>
      <description>&lt;UL&gt;
&lt;LI&gt;What if you do something like this:&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="script_token"&gt;WeekStart(&lt;/SPAN&gt;&lt;SPAN class="bnf_token"&gt;dateField , -1 , 0&lt;/SPAN&gt;&lt;SPAN class="statement"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="statement"&gt;WeekEnd(dateField , -1 , 0)&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="statement"&gt;OR &lt;STRONG&gt;dayname(WeekEnd(dateField , -1 , 0))&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Sep 2022 20:51:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Start-week-from-Monday-in-the-Autocalendar-script/m-p/1985635#M81370</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2022-09-26T20:51:08Z</dc:date>
    </item>
  </channel>
</rss>

