<?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: Calendar Script - Debug Help Needed in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273784#M709502</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks a lot Martin that's worked - really appreciate your help and such a speedy response. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would I be right in thinking if I wanted to use it as a variable I would just declare: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Let vtoday = today()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if there would be any point though - just curious &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Jul 2011 09:51:39 GMT</pubDate>
    <dc:creator>stuwannop</dc:creator>
    <dc:date>2011-07-12T09:51:39Z</dc:date>
    <item>
      <title>Calendar Script - Debug Help Needed</title>
      <link>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273781#M709499</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;&lt;/P&gt;&lt;P&gt;I'm quite new to Qlikview (especially scripting) and I have a calendar script below (it's not mine) which should take the Max and Min dates and populate them in a calendar table. My table is called Invoicing, using the date field. When I run it, I am getting the error in green below. It looks like I'm missing a bracket somewhere - I've narrowed it down to the IF statements using the debugger - can anybody spot where I am going wrong? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help, the script is at the bottom of the post. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stu&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Error in expression:&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;')' expected&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Calendar:&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;load&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Date as Date,&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Year(Date) as CalendarYear,&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt; &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InYearToDate (Date, , 0),1,0) as Cal_YTD_TY,&amp;nbsp; &lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InYearToDate (Date, , -1),1,0) as Cal_YTD_LY,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;quartername(Date) as Cal_CalendarQuarter,&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Month(Date)&amp;amp;'-'&amp;amp;right(year(Date),4) as Cal_MonthYear,&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Month(Date) as Cal_Month,&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Day(Date) as Cal_Day,&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Week(Date) as Cal_Week,&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;Weekday(Date) as Cal_WeekDay&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000;"&gt;&lt;EM&gt;resident Date&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SCRIPT: &lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;// Dynamic Date range is built from data field - Date registered - change as required&lt;BR /&gt;// Replace all instances of MyDate with the key date field&lt;BR /&gt;// Replace instance of MyTable with the key date field resident table name&lt;BR /&gt;// All generated date fields will be prefaced with Cal_&lt;/P&gt;&lt;P&gt;Range:&lt;BR /&gt;LOAD&lt;BR /&gt; min(Date) as startdate,&lt;BR /&gt; max(Date) as enddate&lt;BR /&gt;resident Invoice;&lt;/P&gt;&lt;P&gt;//Peek out the values for later use&lt;BR /&gt;let vStart = peek('startdate',-1,'Range')-1;&lt;BR /&gt;let vEnd = peek('enddate',-1,'Range');&lt;BR /&gt;let vRange = $(vEnd) - $(vStart);&lt;/P&gt;&lt;P&gt;//Remove Range table as no longer needed&lt;BR /&gt;Drop table Range;&lt;/P&gt;&lt;P&gt;//Generate a table with a row per date between the range above&lt;BR /&gt;Date:&lt;BR /&gt;Load&lt;BR /&gt; $(vStart)+recno() as Date&lt;BR /&gt;autogenerate $(vRange);&lt;/P&gt;&lt;P&gt;//Calculate the Parts you need to examine&lt;BR /&gt;Calendar:&lt;BR /&gt;load&lt;BR /&gt; Date as Date,&lt;BR /&gt;// date(Date,'dd/mm/yyyy') as Cal_FullDate,&lt;BR /&gt; Year(Date) as CalendarYear,&lt;BR /&gt; 'Q'&amp;amp;ceil(Month(Date)/3) AS Cal_Quarter,&lt;BR /&gt;// right(yearname(Date,0,$(vFiscalMonthStart)),4) as Cal_FiscalYear,&lt;BR /&gt;// if(InYear (Date, $(vToday), -1),1) as Cal_FULL_LY, // All Dates Last Year&lt;BR /&gt;// if(InYear (Date, $(vToday), 0),1) as Cal_FULL_TY, // All Dates This Year&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InYearToDate (Date, $(vToday), 0),1,0) as Cal_YTD_TY,&amp;nbsp; // All Dates to Date this Year&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InYearToDate (Date, $(vToday), -1),1,0) as Cal_YTD_LY,&amp;nbsp; // All Dates to Date Last Year&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InQuarterToDate (Date, $(vToday), 0),1,0) as Cal_QTR_TQ,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InQuarterToDate (Date, $(vToday), -1),1,0) as Cal_QTR_LQ,&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InMonthToDate(Date, $(vToday), 0),1,0) as Cal_MNTH_TM,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InMonthToDate(Date, $(vToday), -1),1,0) as Cal_MNTH_LM,&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;//&amp;nbsp; YTD_LY, used in Expressions Ex. Sum(Sales*YTD_LY)&lt;BR /&gt; quartername(Date) as Cal_CalendarQuarter,&lt;BR /&gt;// quartername(Date,0,$(vFiscalMonthStart)) as Cal_FiscalQuarter,&lt;BR /&gt;// Month(Date)&amp;amp;'-'&amp;amp;right(yearname(Date,0,11),4) as Cal_FiscalMonthYear, //Fiscal!&lt;BR /&gt; Month(Date)&amp;amp;'-'&amp;amp;right(year(Date),4) as Cal_MonthYear,&lt;BR /&gt; Month(Date) as Cal_Month,&lt;BR /&gt; Day(Date) as Cal_Day,&lt;BR /&gt; Week(Date) as Cal_Week,&lt;BR /&gt; Weekday(Date) as Cal_WeekDay&lt;BR /&gt;resident Date;&lt;/P&gt;&lt;P&gt;//Tidy up&lt;BR /&gt;Drop table Date;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 09:19:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273781#M709499</guid>
      <dc:creator>stuwannop</dc:creator>
      <dc:date>2011-07-12T09:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calendar Script - Debug Help Needed</title>
      <link>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273782#M709500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm not sure but it could be this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;Range:&lt;BR /&gt;LOAD&lt;BR /&gt; min(Date) as startdate,&lt;BR /&gt; max(Date) as enddate&lt;BR /&gt;resident Invoice;&lt;BR /&gt;//Peek out the values for later use&lt;BR /&gt;let vStart = num(peek('startdate',-1,'Range')-1);&lt;BR /&gt;let vEnd = num(peek('enddate',-1,'Range'));&lt;BR /&gt;let vRange = $(vEnd) - $(vStart);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 09:29:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273782#M709500</guid>
      <dc:creator>martin59</dc:creator>
      <dc:date>2011-07-12T09:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calendar Script - Debug Help Needed</title>
      <link>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273783#M709501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excuse me, I've found your error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where do you declare you variable vToday ? This variable hasn't value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, you can use the today() function like this &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;//Calculate the Parts you need to examine&lt;BR /&gt;Calendar:&lt;BR /&gt;load&lt;BR /&gt; Date as Date,&lt;BR /&gt;// date(Date,'dd/mm/yyyy') as Cal_FullDate,&lt;BR /&gt; Year(Date) as CalendarYear,&lt;BR /&gt; 'Q'&amp;amp;ceil(Month(Date)/3) AS Cal_Quarter,&lt;BR /&gt;// right(yearname(Date,0,$(vFiscalMonthStart)),4) as Cal_FiscalYear,&lt;BR /&gt;// if(InYear (Date, today(), -1),1) as Cal_FULL_LY, // All Dates Last Year&lt;BR /&gt;// if(InYear (Date, today(), 0),1) as Cal_FULL_TY, // All Dates This Year&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InYearToDate (Date, today(), 0),1,0) as Cal_YTD_TY,&amp;nbsp; // All Dates to Date this Year&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InYearToDate (Date, today(), -1),1,0) as Cal_YTD_LY,&amp;nbsp; // All Dates to Date Last Year&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InQuarterToDate (Date, today(), 0),1,0) as Cal_QTR_TQ,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InQuarterToDate (Date, today(), -1),1,0) as Cal_QTR_LQ,&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InMonthToDate(Date, today(), 0),1,0) as Cal_MNTH_TM,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(InMonthToDate(Date, today(), -1),1,0) as Cal_MNTH_LM,&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;//&amp;nbsp; YTD_LY, used in Expressions Ex. Sum(Sales*YTD_LY)&lt;BR /&gt; quartername(Date) as Cal_CalendarQuarter,&lt;BR /&gt;// quartername(Date,0,$(vFiscalMonthStart)) as Cal_FiscalQuarter,&lt;BR /&gt;// Month(Date)&amp;amp;'-'&amp;amp;right(yearname(Date,0,11),4) as Cal_FiscalMonthYear, //Fiscal!&lt;BR /&gt; Month(Date)&amp;amp;'-'&amp;amp;right(year(Date),4) as Cal_MonthYear,&lt;BR /&gt; Month(Date) as Cal_Month,&lt;BR /&gt; Day(Date) as Cal_Day,&lt;BR /&gt; Week(Date) as Cal_Week,&lt;BR /&gt; Weekday(Date) as Cal_WeekDay&lt;BR /&gt;resident Date;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 09:35:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273783#M709501</guid>
      <dc:creator>martin59</dc:creator>
      <dc:date>2011-07-12T09:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calendar Script - Debug Help Needed</title>
      <link>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273784#M709502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks a lot Martin that's worked - really appreciate your help and such a speedy response. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would I be right in thinking if I wanted to use it as a variable I would just declare: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Let vtoday = today()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if there would be any point though - just curious &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 09:51:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273784#M709502</guid>
      <dc:creator>stuwannop</dc:creator>
      <dc:date>2011-07-12T09:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calendar Script - Debug Help Needed</title>
      <link>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273785#M709503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you can use a variable like this :&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;LET vToday = Today();&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jul 2011 10:04:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calendar-Script-Debug-Help-Needed/m-p/273785#M709503</guid>
      <dc:creator>martin59</dc:creator>
      <dc:date>2011-07-12T10:04:56Z</dc:date>
    </item>
  </channel>
</rss>

