2 Replies Latest reply: Aug 1, 2017 9:40 PM by Sunny Talwar RSS

    Preceding Load not working

    Justin Dallas

      Hello Folks,

       

      I'm using QlikSense Desktop, and my Preceding load fails.  I'm not sure what's going on.  The script is here.  I'm on version June 2017 if that helps.

       

      Let varMinDate = Num(Makedate(2015,7,1));
      Let varMaxDate = Num(Makedate(2020,12,31));
      
      //Let v2013 = (Makedate(2013,8,2) - 6);
      Let v2014 = WeekStart((Makedate(2013,8,3));
      Let v2015 = WeekStart((Makedate(2014,8,1));
      Let v2016 = WeekStart((Makedate(2015,8,6));
      Let v2017 = WeekStart((Makedate(2016,8,5));
      Let v2018 = WeekStart((Makedate(2017,8,4));
      Let v2019 = WeekStart((Makedate(2018,8,3));
      Let v2020 = WeekStart((Makedate(2019,8,1));
      Let v2021 = WeekStart((Makedate(2020,8,7));
      Let v2022 = WeekStart((Makedate(2021,8,6));
      
      TempCalendar:
      LOAD date($(varMinDate)+IterNo()-1) AS TempDate
      AUTOGENERATE (1)
      WHILE $(varMinDate)+IterNo()-1<= $(varMaxDate)
      ;
      
      FiscalCalendar:
      LOAD *, If(FiscalDate >= $(v2014) AND FiscalDate < $(v2015), $(v2015), 0) AS TempEndingDate
      ;
      LOAD
                TempDate AS FiscalDate,
                Year (TempDate) AS FiscalYear,
                Month (TempDate) AS FiscalMonth,
                Day (TempDate) AS FiscalDay,
                Week(TempDate) AS FiscalWeek
      Resident TempCalendar
      Order by TempDate ASC;
      
      EXIT Script
      ;
      
      

       

       

      Is it disabled in QlikSense Desktop?

       

      The error I get is

       

      The following error occurred:

      Unexpected token: 'FiscalDate', expected one of: ',', 'follows', 'follows', 'From', 'From_Field', ':', 'OPERATOR_PLUS', ...

      The error occurred here:

      FiscalCalendar: LOAD *, If(FiscalDate >= AND >>>>>>FiscalDate<<<<<< < , , 0) AS TempEndingDate

        • Re: Preceding Load not working
          buck master

          Replace this script and it will work. You needed an extra ")" over the Let statements.

           

          Let varMinDate = Num(Makedate(2015,7,1)); 

          Let varMaxDate = Num(Makedate(2020,12,31)); 

           

          //Let v2013 = (Makedate(2013,8,2) - 6); 

          Let v2014 = WeekStart((Makedate(2013,8,3))); 

          Let v2015 = WeekStart((Makedate(2014,8,1))); 

          Let v2016 = WeekStart((Makedate(2015,8,6))); 

          Let v2017 = WeekStart((Makedate(2016,8,5))); 

          Let v2018 = WeekStart((Makedate(2017,8,4))); 

          Let v2019 = WeekStart((Makedate(2018,8,3))); 

          Let v2020 = WeekStart((Makedate(2019,8,1))); 

          Let v2021 = WeekStart((Makedate(2020,8,7))); 

          Let v2022 = WeekStart((Makedate(2021,8,6))); 

           

          TempCalendar: 

          LOAD date($(varMinDate)+IterNo()-1) AS TempDate 

          AUTOGENERATE (1) 

          WHILE $(varMinDate)+IterNo()-1<= $(varMaxDate) 

           

          FiscalCalendar: 

          LOAD *,

          If(FiscalDate >= $(v2014) AND FiscalDate < $(v2015), $(v2015), 0) AS TempEndingDate ;

           

           

          LOAD 

                    TempDate AS FiscalDate, 

                    Year (TempDate) AS FiscalYear, 

                    Month (TempDate) AS FiscalMonth, 

                    Day (TempDate) AS FiscalDay, 

                    Week(TempDate) AS FiscalWeek 

          Resident TempCalendar 

          Order by TempDate ASC; 

           

          EXIT Script 

          • Re: Preceding Load not working
            Sunny Talwar

            You might need to use single quotes around your variable

            If(FiscalDate >= '$(v2014)' AND FiscalDate < '$(v2015)', '$(v2015)', 0) AS TempEndingDate

             

            Alternatively, add Num() to your variables

            LET v2014 = Num(WeekStart(Makedate(2013, 8, 3)));

             

            and then you don't need the single quotes around your variable