1 Reply Latest reply: May 24, 2017 11:25 AM by Peter Cammaert RSS

    QlikSense Calendar Load Error:  Error in expression: ')' expected

    Anike Ditchfield

      Hi,

       

      I'm currently in the process of adding some calendars to my data load, however experiencing some problems. There are 2 calendars for 2 unconnected data sources within the load. My calendar script is as follows:

       

      //Sales Calendar Script

       

       

      SalesCalendar:

      Load

      TempDate AS SalesDate,

      week(TempDate) As SalesWeek,

      Year(TempDate) As SalesYear,

      Month(TempDate) As SalesMonth,

      Day(TempDate) As SalesDay,

      'Q' & ceil(month(TempDate) / 3) AS SalesQuarter,

      Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as SalesWeekYear,

      WeekDay(TempDate) as SalesWeekDay,

      If(Num([TempDate]) >=  Num([TempDate]), 0, 0)  As Sales_Current_YTD,

      If(Num([TempDate]) >=  Num([TempDate]), -1, 0)  As Sales_LY_YTD,

      //

      If( InWeekToDate (TempDate, $(CurrentDate),0),1) as SalesWTD, // All Dates This Week To Date This Year

      If( InWeekToDate (TempDate, $(CurrentDate), -1),1) as SalesLWTD, // All Dates Previous Week To Date

        If( InMonthToDate (TempDate, $(CurrentDate),0),1) as Sales_MTD_TY, // All Dates This Month To Date This Year

      If( InMonthToDate (TempDate, $(CurrentDate),-12),1) as Sales_MTD_LY, // All Dates This Month To Date Last Year

      If( InMonthToDate (TempDate, $(CurrentDate), -1),1) as Sales_LM_MTD, // All Dates Previous Month To Date

      //

      inyeartodate(TempDate, $(varToday), 0, 3) * -1  AS SalesFinancialCurYTDFlag,

      inyeartodate(TempDate, $(varToday), -1, 3) * -1 AS SalesFinancialLastYTDFlag

       

      ;

       

       

      //=== Generate a temp table of dates ===

      LOAD

      date(mindate + IterNo()) AS TempDate

      ,maxdate // Used in InYearToDate() above, but not kept

      WHILE mindate + IterNo() <= maxdate;

       

       

      //=== Get min/max dates from Field ===/

      LOAD

      min(FieldValue([Date], recno()))-1 as mindate,

      max(FieldValue([Date], recno())) as maxdate

      AUTOGENERATE FieldValueCount([Date]);

       

       

      //Supplier Deliveries Calendar Script

       

       

      SupDelRR:

      Load

      TempDate AS SupDelRRDate,

      week(TempDate) As SupDelRRWeek,

      Year(TempDate) As SupDelRRYear,

      Month(TempDate) As SupDelRRMonth,

      Day(TempDate) As SupDelRRDay,

      'Q' & ceil(month(TempDate) / 3) AS SupDelRRQuarter,

      Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as SupDelRRWeekYear,

      WeekDay(TempDate) as SupDelRRWeekDay,

      If(Num([TempDate]) >=  Num([TempDate]), 0, 0)  As SupDelRR_Current_YTD,

      If(Num([TempDate]) >=  Num([TempDate]), -1, 0)  As SupDelRR_LY_YTD,

       

      //

      If( InWeekToDate (TempDate, $(CurrentDate),0),1) as SupDelRRWTD, // All Dates This Week To Date This Year

      If( InWeekToDate (TempDate, $(CurrentDate), -1),1) as SupDelRRLWTD, // All Dates Previous Week To Date

      If( InMonthToDate (TempDate, $(CurrentDate),0),1) as SupDelRR_MTD_TY, // All Dates This Month To Date This Year

      If( InMonthToDate (TempDate, $(CurrentDate),-12),1) as SupDelRR_MTD_LY, // All Dates This Month To Date Last Year

      If( InMonthToDate (TempDate, $(CurrentDate), -1),1) as SupDelRR_LM_MTD, // All Dates Previous Month To Date

      //

      inyeartodate(TempDate, $(varToday), 0, 3) * -1  AS SupDelRRFinancialCurYTDFlag,

      inyeartodate(TempDate, $(varToday), -1, 3) * -1 AS SupDelRRFinancialLastYTDFlag

       

       

      ;

       

       

      //=== Generate a temp table of dates ===

      LOAD

      date(mindate + IterNo()) AS TempDate

      ,maxdate // Used in InYearToDate() above, but not kept

      WHILE mindate + IterNo() <= maxdate;

       

       

      //=== Get min/max dates from Field ===/

      LOAD

      min(FieldValue([receiptreturndate], recno()))-1 as mindate,

      max(FieldValue([receiptreturndate], recno())) as maxdate

      AUTOGENERATE FieldValueCount([receiptreturndate]);

       

       

      /////////////////////////////////////////////////////////////////////

       

       

       

       

      And the full error message is below:

       

      The following error occurred:

       

      Error in expression:

       

       

      ')' expected

       

       

      ---

       

       

      The error occurred here:

       

       

      SalesCalendar:

       

       

      Load

       

       

      TempDate AS SalesDate,

       

       

      week(TempDate) As SalesWeek,

       

       

      Year(TempDate) As SalesYear,

       

       

      Month(TempDate) As SalesMonth,

       

       

      Day(TempDate) As SalesDay,

       

       

      'Q' & ceil(month(TempDate) / 3) AS SalesQuarter,

       

       

      Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as SalesWeekYear,

       

       

      WeekDay(TempDate) as SalesWeekDay,

       

       

       

      If(Num([TempDate]) >= Num([TempDate]), 0, 0) As Sales_Current_YTD,

       

       

      If(Num([TempDate]) >= Num([TempDate]), -1, 0) As Sales_LY_YTD,

       

       

       

      If( InWeekToDate (TempDate, ,0),1) as SalesWTD,

       

       

      If( InWeekToDate (TempDate, , -1),1) as SalesLWTD,

       

       

      If( InMonthToDate (TempDate, ,0),1) as Sales_MTD_TY,

       

       

      If( InMonthToDate (TempDate, ,-12),1) as Sales_MTD_LY,

       

       

      If( InMonthToDate (TempDate, , -1),1) as Sales_LM_MTD,

       

       

       

      inyeartodate(TempDate, , 0, 3) * -1 AS SalesFinancialCurYTDFlag,

       

       

      inyeartodate(TempDate, , -1, 3) * -1 AS SalesFinancialLastYTDFlag

       

       

      ---

       

       

      Data has not been loaded. Please correct the error and try loading again.
      ////////////////////////////////////////////////////////////////////////////////////////////////
      Would be grateful for any useful help and advice with this one - thanks in advance