<?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: Variable for Month in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Variable-for-Month/m-p/1830954#M1214517</link>
    <description>&lt;P&gt;you need to define the business rules.&amp;nbsp; if the 1st of the month falls on a Tuesday is that counted towards&amp;nbsp; the prior month?&amp;nbsp; maybe your determining factor is when the 1st day of the week falls?&amp;nbsp; or is it based on the number of days in the week - whichever is greater?&amp;nbsp; either way you can use the week&amp;nbsp; to test if the calendar date falls under the current month or prior month.&lt;/P&gt;&lt;P&gt;this sample assumes that any calendar date falling on the same week where sunday is prior month will be counted towards the prior month:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;dates:
load date, week(date) as week, if(weekday(date)='Sun',MonthStart(date)) as tmpSHIPMONTH, year(date) &amp;amp; '|' &amp;amp; Week(date) as Yearweek, weekday(date) as weekday, day(date) as day;
load date(today()-iterno()) as date while iterno()&amp;lt;300;
load 1 autogenerate(1);

NoConcatenate
weeks:
load distinct tmpSHIPMONTH as SHIPMONTH, Yearweek 
Resident dates where not isnull(tmpSHIPMONTH);

inner join (dates)
load * resident weeks;

drop table weeks;
drop field tmpSHIPMONTH;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_0-1629850305811.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/60662iE8572F75257885DD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_0-1629850305811.png" alt="edwin_0-1629850305811.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Aug 2021 00:12:09 GMT</pubDate>
    <dc:creator>edwin</dc:creator>
    <dc:date>2021-08-25T00:12:09Z</dc:date>
    <item>
      <title>Variable for Month</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-for-Month/m-p/1829580#M1214348</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I am trying to create a variable for shipping month which at times is different from the actual calendar month - i.e. if the first few days of April like the 1st and 2nd fall on a Thursday and Friday I still want these dates to be classed in the month of March.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my expressions, I am using a&amp;nbsp; vCurrentMonth variable which is built from month(today()) but this will give the wrong value in the instance above when the shipping month is different from the calendar month.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions would be greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Aug 2021 22:19:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-for-Month/m-p/1829580#M1214348</guid>
      <dc:creator>NickBentley</dc:creator>
      <dc:date>2021-08-18T22:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for Month</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-for-Month/m-p/1830954#M1214517</link>
      <description>&lt;P&gt;you need to define the business rules.&amp;nbsp; if the 1st of the month falls on a Tuesday is that counted towards&amp;nbsp; the prior month?&amp;nbsp; maybe your determining factor is when the 1st day of the week falls?&amp;nbsp; or is it based on the number of days in the week - whichever is greater?&amp;nbsp; either way you can use the week&amp;nbsp; to test if the calendar date falls under the current month or prior month.&lt;/P&gt;&lt;P&gt;this sample assumes that any calendar date falling on the same week where sunday is prior month will be counted towards the prior month:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;dates:
load date, week(date) as week, if(weekday(date)='Sun',MonthStart(date)) as tmpSHIPMONTH, year(date) &amp;amp; '|' &amp;amp; Week(date) as Yearweek, weekday(date) as weekday, day(date) as day;
load date(today()-iterno()) as date while iterno()&amp;lt;300;
load 1 autogenerate(1);

NoConcatenate
weeks:
load distinct tmpSHIPMONTH as SHIPMONTH, Yearweek 
Resident dates where not isnull(tmpSHIPMONTH);

inner join (dates)
load * resident weeks;

drop table weeks;
drop field tmpSHIPMONTH;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_0-1629850305811.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/60662iE8572F75257885DD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_0-1629850305811.png" alt="edwin_0-1629850305811.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 00:12:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-for-Month/m-p/1830954#M1214517</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-08-25T00:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Variable for Month</title>
      <link>https://community.qlik.com/t5/QlikView/Variable-for-Month/m-p/1830955#M1214518</link>
      <description>&lt;P&gt;as you can see dec 1 to 5 fall under nov bec they are on the same week as the last of Nov which included the sunday for that week&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 00:15:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variable-for-Month/m-p/1830955#M1214518</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2021-08-25T00:15:28Z</dc:date>
    </item>
  </channel>
</rss>

