4 Replies Latest reply: Oct 2, 2013 10:05 AM by Christian Conejero RSS

    Year Start and End

    alvinford ford

      Hi All,


      I have the following requirement. Need your help to get it !


      I have to take my year start as last Sunday of April i.e. 28/04/2013.The Week is from Sunday to Saturday. How can I develop this logic in Qlikview. So from 28/04/2013 to 26/04/2014 need to take as "This Year" and 29/04/2012 to 27/04/2013 as "Last Year". How can I derive this.




        • Re: Year Start and End
          Stefan Wühl

          Try something like



          LOAD if(Date < weekstart(makedate(year(today())+1,4,30),0,-1) and Date >= weekstart(makedate(year(today()),4,30),0,-1), 'This Year',

                      if(Date < weekstart(makedate(year(today()),4,30),0,-1) and Date >= weekstart(makedate(year(today())-1,4,30),0,-1), 'Last Year')) as YearFlag,



          Date(makedate(2012)+recno()-1) as Date

          AUTOGENERATE 1000;


          weekstart( makedate(2013,4,30), 0, -1) should return the last sunday in April 2013, change the input date for other years.

          • Re: Year Start and End
            Christian Conejero



            I recomend you to do that in the script.

            Also I recomend you not to use an if clause.

            Instead do the next.



            Year(Date)                                        as Year,

            Year(Date-Nº of days)                  as FixedYear


            Being Nº of days the number of days between that last sunday of April that you want, and your Date data.

            You'll have to work it out a little bit more for your script.

            good luck.