9 Replies Latest reply: Apr 22, 2014 6:56 AM by Richard Pearce RSS

    Scripting - Check Last Working Day

    Richard Pearce

      Hi,

       

      I have a challenge and I'd like to know if there's a elegant solution.

       

      My Script loads a calendar and then applies a flag for working days (i.e. Monday - Friday less and Public Holidays). So I end up with something like this:

       

      Date                         ,Working Day Flag

      3-Apr-2014               ,1

      4-Apr-2014               ,1

      5-Apr-2014               ,0

      6-Apr-2014               ,0

      7-Apr-2014               ,1

      8-Apr-2014               ,1

       

      I want to add another column [Last Working Day] which gives the values of the last date where the [Working Day Flag] was 1 or the [Date] value if it is a working day. For example:

       

      Date                         ,Working Day Flag     ,Last Working Day

      3-Apr-2014               ,1                               ,3-Apr-2014

      4-Apr-2014               ,1                               ,4-Apr-2014

      5-Apr-2014               ,0                               ,4-Apr-2014

      6-Apr-2014               ,0                               ,4-Apr-2014

      7-Apr-2014               ,1                               ,7-Apr-2014

      8-Apr-2014               ,1                               ,8-Apr-2014

       

      I can do this using previous() although I want it to be able to work where there are several consecutive none working days, as Previous() is limited to three iterations I'd like to know if there's another technique for this.

       

      Many thanks

       

      Richard