<?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: Determine Trading Calendar Month in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527605#M1129801</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are several possibilities:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Using Intervalmatch&lt;/P&gt;&lt;P&gt;2. Create in (a additionally) (link) table for each day the trade month or then per mapping&lt;/P&gt;&lt;P&gt;3. Create within the transaction table the trade month per algorithm&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which is the best? It will depend from your data model, but the order here is rather a recommendation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Dec 2013 14:00:52 GMT</pubDate>
    <dc:creator>marcus_sommer</dc:creator>
    <dc:date>2013-12-04T14:00:52Z</dc:date>
    <item>
      <title>Determine Trading Calendar Month</title>
      <link>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527603#M1129799</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;I have a table (excel file) which shows the Trading Calendar for the year (see attached "TCM"&amp;nbsp; image). It contains these fields:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Month Start, Month End, Trading Month&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;e.g:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;2013/12/01, 2013/12/28, December 2013&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I load other files (e.g. transaction extracts) they have certain date fields, like "Posted Date", which I load as follows:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;DATE(DATE#( [Posted Date], 'DD-MMM-YY')) as [Posted Date],&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to create new fields that match the Trading Calendar to see in which Month the transaction falls. So in the above example the new field will be called [Posted Date TCM], and if the posted date is 2013/12/28 then the Trading Month is December 2013, but if the Posted Date is 2013/12/29 then the Trading Month is January 2014.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the best way to go about this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it helps, each month-end is the last Saturday of the month, so using that logic I can possibly bypass the need for loading the excel file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gerhard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Dec 2013 13:25:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527603#M1129799</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2013-12-04T13:25:44Z</dc:date>
    </item>
    <item>
      <title>Re: Determine Trading Calendar Month</title>
      <link>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527604#M1129800</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;I suggest that you use interval match to get the periods into your document. That way you are not hard-coding the rule into your model, but you would need to update the trading months spreadsheet once per year. The code would look like this (assuming your transactions are in a table called Transactions).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;T_TradingMonths:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD Month Start, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; Month End, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; Trading Month&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;From TradingMonths.xlsx (ooxml etc...);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Left Join (Transactions)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;IntervalMatch([Posted Date])&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; Month Start, &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; Month End&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Resident T_TradingMonths;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Left Join (Transactions)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD * Resident T_TradingMonths;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Drop Table T_TradingMonths;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The last load brings the field into the fact table. If you want to get it into the calendar table instead, change Transactions to the name of your calendar table and [Posted Date] to the calendar data field.&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>Wed, 04 Dec 2013 13:55:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527604#M1129800</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2013-12-04T13:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Determine Trading Calendar Month</title>
      <link>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527605#M1129801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are several possibilities:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Using Intervalmatch&lt;/P&gt;&lt;P&gt;2. Create in (a additionally) (link) table for each day the trade month or then per mapping&lt;/P&gt;&lt;P&gt;3. Create within the transaction table the trade month per algorithm&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which is the best? It will depend from your data model, but the order here is rather a recommendation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Dec 2013 14:00:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527605#M1129801</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2013-12-04T14:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Determine Trading Calendar Month</title>
      <link>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527606#M1129802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. This is not 100% what I had in mind, but it seems to work okay.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On a related note:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I determine the last Saturday in any given month?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Dec 2013 14:18:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527606#M1129802</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2013-12-04T14:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: Determine Trading Calendar Month</title>
      <link>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527607#M1129803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;= date(monthend(date) - (if(num(weekday(monthend(date))) = 5, - 2, num(weekday(monthend(date)))) + 1), 'DD.MM.YYYY')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Dec 2013 15:16:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527607#M1129803</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2013-12-04T15:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Determine Trading Calendar Month</title>
      <link>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527608#M1129804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Marcus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I now have this in my load script, but it returns null:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;date(monthend([Posted Date]) - (if(num(weekday(monthend([Posted Date]))) = 5, - 2, num(weekday(monthend([Posted Date])))) + 1), 'DD-MM-YYYY') as [Posted Date Month-End],&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 05:43:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527608#M1129804</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2013-12-05T05:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Determine Trading Calendar Month</title>
      <link>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527609#M1129805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay so I resolved this by doing something different. Instead of having an excel file showing the Month Start and Month End, I created an excel file with 2 fields - Posted Date and Trading Calendar Month-End.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then auto-filled each date for the last and next 3 years in Column A, and in Column B I calculated that particular day's Trading Calendar Month-End (last Sat of the month) using this formula:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;=IF(A2&amp;gt;(DATE(YEAR(A2),MONTH(A2)+1,1))-WEEKDAY(DATE(YEAR(A2),MONTH(A2)+1,1)),(DATE(YEAR(A2),MONTH(A2)+2,1))-WEEKDAY(DATE(YEAR(A2),MONTH(A2)+2,1)),(DATE(YEAR(A2),MONTH(A2)+1,1))-WEEKDAY(DATE(YEAR(A2),MONTH(A2)+1,1)))&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then do a Mapping Load using that table. This is faster than the interval match, and I think can more easily be used in the load script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 06:12:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527609#M1129805</guid>
      <dc:creator>gerhardl</dc:creator>
      <dc:date>2013-12-05T06:12:15Z</dc:date>
    </item>
    <item>
      <title>Re: Determine Trading Calendar Month</title>
      <link>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527610#M1129806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gerhard,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for me it had worked. I assume that your &lt;EM&gt;&lt;STRONG&gt;[Posted Date]&lt;/STRONG&gt;&lt;/EM&gt; won't recognized as date and must be converted per date#() within the expression. The solutions with mapping is definitely the fastest way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Marcus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Dec 2013 08:54:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Determine-Trading-Calendar-Month/m-p/527610#M1129806</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2013-12-05T08:54:04Z</dc:date>
    </item>
  </channel>
</rss>

