Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a complex requirement in my project.
To put it in simple words I want to add a flag and repeat my Amount and TXN numbers based on a condition.
Below is my original script.
Table1:
LOAD * INLINE [
Key, Flag
1, Y
2, N
3, N
];
Table2:
LOAD * INLINE [
Key, Amount, TXN, Tier, Date
1, 10, 1, A, 5/12/2016
2, 20, 2, B, 3/12/2016
2, 40, 2, C, 3/12/2016
3, 30, 3, C, 1/12/2016
];
Now I want to insert a new Tier into Table2 called as 'D' .
And duplicate the records in table 2 when Flag = Y in Table 1.
Any help/sample code appreciated.
Thanks in advance.
Regards,
Roy
Check out the attached script:
MappingTable1:
Mapping
LOAD * INLINE [
Key, Flag
1, Y
2, N
3, N
];
Table2:
LOAD *,
ApplyMap('MappingTable1', Key) as Flag;
LOAD * INLINE [
Key, Amount, TXN, Tier, Date
1, 10, 1, A, 5/12/2016
2, 20, 2, B, 3/12/2016
2, 40, 2, C, 3/12/2016
3, 30, 3, C, 1/12/2016
];
Concatenate(Table2)
LOAD Key,
Amount,
TXN,
Flag,
'D' as Tier,
Date
Resident Table2
Where Flag = 'Y';
Check out the attached script:
MappingTable1:
Mapping
LOAD * INLINE [
Key, Flag
1, Y
2, N
3, N
];
Table2:
LOAD *,
ApplyMap('MappingTable1', Key) as Flag;
LOAD * INLINE [
Key, Amount, TXN, Tier, Date
1, 10, 1, A, 5/12/2016
2, 20, 2, B, 3/12/2016
2, 40, 2, C, 3/12/2016
3, 30, 3, C, 1/12/2016
];
Concatenate(Table2)
LOAD Key,
Amount,
TXN,
Flag,
'D' as Tier,
Date
Resident Table2
Where Flag = 'Y';