Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have the following table (I have only enclosed a subset of the table):
Territory | Date | Type | Number of Days |
SKAMC06 | 10/02/2016 | Holiday | 3 |
RTSM321 | 01/09/2015 | Meeting | 3 |
RTSM321 | 07/09/2015 | Working | 5 |
RTSM321 | 16/03/2015 | Holiday | 5 |
RTSM125 | 18/03/2016 | Meeting | 4 |
I would like to transform it in the load process to the following using the date in the first table as the start date and the number of days as the number of rows to populate forward. I would also like to exclude weekends, so in the example 18/03/2016 is a Friday so when the rows are auto populated it does not include 19/03 and 20/03:
Territory | Date | Type | Number of Days |
SKAMC06 | 10/02/2016 | Holiday | 3 |
SKAMC06 | 11/02/2016 | Holiday | 3 |
SKAMC06 | 12/02/2016 | Holiday | 3 |
RTSM321 | 01/09/2015 | Meeting | 3 |
RTSM321 | 02/09/2015 | Meeting | 3 |
RTSM321 | 03/09/2015 | Meeting | 3 |
RTSM321 | 07/09/2015 | Working | 5 |
RTSM321 | 08/09/2015 | Working | 5 |
RTSM321 | 09/09/2015 | Working | 5 |
RTSM321 | 10/09/2015 | Working | 5 |
RTSM321 | 11/09/2015 | Working | 5 |
RTSM321 | 16/03/2015 | Holiday | 5 |
RTSM321 | 17/03/2015 | Holiday | 5 |
RTSM321 | 18/03/2015 | Holiday | 5 |
RTSM321 | 19/03/2015 | Holiday | 5 |
RTSM321 | 20/03/2015 | Holiday | 5 |
RTSM125 | 18/03/2016 | Meeting | 4 |
RTSM125 | 21/03/2016 | Meeting | 4 |
RTSM125 | 22/03/2016 | Meeting | 4 |
RTSM125 | 23/03/2016 | Meeting | 4 |
Any help would be gratefully received.
Thanks in advance
Chris
Maybe like
Set DateFormat = 'DD/MM/YYYY';
LOAD *,
LastWorkDate(Date, iterno()) as NewDate
INLINE [
Territory, Date, Type, Number of Days
SKAMC06, 10/02/2016, Holiday, 3
RTSM321, 01/09/2015, Meeting, 3
RTSM321, 07/09/2015, Working, 5
RTSM321, 16/03/2015, Holiday, 5
RTSM125, 18/03/2016, Meeting, 4
]
WHILE iterno() <= "Number of Days";
Maybe like
Set DateFormat = 'DD/MM/YYYY';
LOAD *,
LastWorkDate(Date, iterno()) as NewDate
INLINE [
Territory, Date, Type, Number of Days
SKAMC06, 10/02/2016, Holiday, 3
RTSM321, 01/09/2015, Meeting, 3
RTSM321, 07/09/2015, Working, 5
RTSM321, 16/03/2015, Holiday, 5
RTSM125, 18/03/2016, Meeting, 4
]
WHILE iterno() <= "Number of Days";
This has worked, many thanks for such a quick reply.