Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Experts,
I'm trying to insert a new field via the LOAD script called "End Date". This is the initial table:
| Prim_key | last_date | Start Date |
|---|---|---|
| 10001 | 3/31/2019 | 4/1/2016 |
| 10001 | 3/31/2019 | 4/1/2017 |
| 10001 | 3/31/2019 | 4/1/2018 |
| 10002 | 12/31/2020 | 1/1/2016 |
| 10002 | 12/31/2020 | 1/1/2018 |
End Date would be defined as follows:
I am having a hard time using set analysis to properly implement this in load script so that it is restricting the calculation to only within the set of values for a particular Prim_key as opposed to getting the min values in the entire table.
Final loaded table should look like this:
| Prim_key | last_date | Start Date | End Date |
|---|---|---|---|
| 10001 | 3/31/2019 | 4/1/2016 | 3/31/2017 |
| 10001 | 3/31/2019 | 4/1/2017 | 3/31/2018 |
| 10001 | 3/31/2019 | 4/1/2018 | 3/31/2019 |
| 10002 | 12/31/2020 | 1/1/2016 | 12/31/2017 |
| 10002 | 12/31/2020 | 1/1/2018 | 12/31/2020 |
I'm trying to insert a new field via the LOAD script called "End Date".
if you want in load script
Table:
LOAD * INLINE [
Prim_key, Start Date, last date
100, 4/1/2016, 3/31/2019
100, 4/1/2017, 3/31/2019
100, 4/1/2018, 3/31/2019
200, 1/1/2016, 12/31/2020
200, 1/1/2018, 12/31/2020
];
Table2:
LOAD
*,
IF(Prim_key = Peek('Prim_key'), Date(Peek('Start Date')-1), [last date]) as [End Date]
Resident Table
Order By Prim_key, [Start Date] desc;
DROP Table Table;

May be like attached
Expression used
If([Start Date]=Date(Max(TOTAL <Prim_key> [Start Date])),Date([last date]),Date(Below(TOTAL [Start Date])-1))
I'm trying to insert a new field via the LOAD script called "End Date".
if you want in load script
Table:
LOAD * INLINE [
Prim_key, Start Date, last date
100, 4/1/2016, 3/31/2019
100, 4/1/2017, 3/31/2019
100, 4/1/2018, 3/31/2019
200, 1/1/2016, 12/31/2020
200, 1/1/2018, 12/31/2020
];
Table2:
LOAD
*,
IF(Prim_key = Peek('Prim_key'), Date(Peek('Start Date')-1), [last date]) as [End Date]
Resident Table
Order By Prim_key, [Start Date] desc;
DROP Table Table;
