<?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 Last WorkDay of Month in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Last-WorkDay-of-Month/m-p/379634#M494753</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a predefined function to determine the last workday of any month in a given year?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to create the Stock Market Calendar where for instance, if AsOfDate = June, 28, 2012&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then, 1 Month ago = May, 25, 2012 (i.e. the last business day a month ago since AddMonths(AsOfDate, -1) = May, 28, 2012 which is a holiday and therefore, the max business day before that is Friday May 25, 2012.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am thinking I will need a reference table of all the holidays in the years before and years to come. But a predefined function for shortcuts to Prior Workday, Next Workday, WorkDay 1 month ago, Last Workday of month etc would be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thoughts anyone?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Aug 2012 18:38:05 GMT</pubDate>
    <dc:creator>avastani</dc:creator>
    <dc:date>2012-08-21T18:38:05Z</dc:date>
    <item>
      <title>Last WorkDay of Month</title>
      <link>https://community.qlik.com/t5/QlikView/Last-WorkDay-of-Month/m-p/379634#M494753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a predefined function to determine the last workday of any month in a given year?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to create the Stock Market Calendar where for instance, if AsOfDate = June, 28, 2012&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then, 1 Month ago = May, 25, 2012 (i.e. the last business day a month ago since AddMonths(AsOfDate, -1) = May, 28, 2012 which is a holiday and therefore, the max business day before that is Friday May 25, 2012.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am thinking I will need a reference table of all the holidays in the years before and years to come. But a predefined function for shortcuts to Prior Workday, Next Workday, WorkDay 1 month ago, Last Workday of month etc would be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thoughts anyone?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 18:38:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Last-WorkDay-of-Month/m-p/379634#M494753</guid>
      <dc:creator>avastani</dc:creator>
      <dc:date>2012-08-21T18:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Last WorkDay of Month</title>
      <link>https://community.qlik.com/t5/QlikView/Last-WorkDay-of-Month/m-p/379635#M494754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sometimes I create a work day flag like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LEFT JOIN (Date) LOAD DISTINCT&lt;BR /&gt; DateID,&lt;BR /&gt; 1 as WorkDayFlag&lt;BR /&gt;RESIDENT Date&lt;BR /&gt;WHERE weekday(DateID)&amp;lt;5&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;&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;&amp;nbsp;&amp;nbsp; // not Saturday or Sunday&lt;BR /&gt; AND match(date(DateID), $(HolidayList))=0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // not holiday&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you can guess, variable HolidayList is a comma-separated list of holidays.&amp;nbsp; So, the last work day of month is easy, it is max Date per month where WorkDayFlag=1.&lt;BR /&gt;As for the next and previous work day, try this:&lt;BR /&gt;previous:&amp;nbsp;&amp;nbsp; firstworkdate(BaseDate, 1, $(HolidayList)) &lt;BR /&gt;next:&amp;nbsp;&amp;nbsp; lastworkdate(BaseDate, 1, $(HolidayList))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Michael&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 19:22:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Last-WorkDay-of-Month/m-p/379635#M494754</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-21T19:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Last WorkDay of Month</title>
      <link>https://community.qlik.com/t5/QlikView/Last-WorkDay-of-Month/m-p/379636#M494755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are indeed some QV functions you can make use of, namely firstworkdate():&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="syntax"&gt;&lt;A name="kanchor522"&gt;&lt;/A&gt;&lt;A name="firstworkdate"&gt;&lt;/A&gt;&lt;SPAN class="Bold"&gt;firstworkdate(&lt;/SPAN&gt;&lt;SPAN class="Italic"&gt;end_date, no_of_workdays {, holiday&lt;/SPAN&gt;} &lt;SPAN class="Bold"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Returns the latest starting date to achieve number_of_workdays (Monday-Friday) ending no later than end_date taking into account any optionally listed holidays. &lt;SPAN class="Italic"&gt;End_date&lt;/SPAN&gt; and &lt;SPAN class="Italic"&gt;holiday&lt;/SPAN&gt; should be valid dates or timestamps. &lt;/P&gt;&lt;P class="example"&gt;Examples:&lt;/P&gt;&lt;P&gt;&lt;SPAN class="Code"&gt;firstworkdate ('2007-03-01', 9)&lt;/SPAN&gt; returns '2007-02-19'&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="Code"&gt;firstworkdate ('2006-12-31', 8, '2006-12-25', '2006-12-26')&lt;/SPAN&gt; returns '2006-12-18'&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=firstworkdate(monthend(today()),1)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;returns 2012-08-31, which seems to be correct (last friday in August), and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;=firstworkdate(addmonths(monthend(today()),1),1)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;returns the last work date in September (2012-09-28). There is also a function called lastworkdate, but I believe you need firstworkdate function here (check out the other and all the other date and time functions in the Help).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can add a list of holidays to the function as shown above to take care of your holidays, too.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2012 19:25:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Last-WorkDay-of-Month/m-p/379636#M494755</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-08-21T19:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Last WorkDay of Month</title>
      <link>https://community.qlik.com/t5/QlikView/Last-WorkDay-of-Month/m-p/379637#M494756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this is good stuff. Both suggestions worked and actually refined my solution. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem I am trying to solve is that I have calendar dates in my fact table from 1976 all the way to today and I am trying to create an asOfDate table which is a join of the MasterCalendar onto itself (Clearly Extremely Inefficient)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. have to use set analysis&lt;/P&gt;&lt;P&gt;2. there is asofdate full outer join onto the MasterCalendar table so I have joins for records that have anything beyond Prior5YearFlag as 0. so in essence if I have asofdate of today, then Jan 1 2000 is 12 years ago and I am not interested in Flags which are more than 5 rolling years away from the as of date.&lt;/P&gt;&lt;P&gt;3. with every new business day, this table has to be recreated/appended to. &lt;/P&gt;&lt;P&gt;4. this table itself adds tot he ultimate size of the app&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so i think this is the most inefficient way to work with as of date. exploring other options.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Aug 2012 03:26:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Last-WorkDay-of-Month/m-p/379637#M494756</guid>
      <dc:creator>avastani</dc:creator>
      <dc:date>2012-08-22T03:26:04Z</dc:date>
    </item>
  </channel>
</rss>

