Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Folks,
I need to achieve a logic which is working in the front end using above function , if I try to achieve same thing using peek in the load script the result are not same. Below are the sample. the red color fount are out put. Please help me out generate the same out put has above does
Id | A1 | B1 | C1 | D1 | above(D1) | peek(D1,-1) |
1 | a | b1 | IN | DE | - | DE |
2 | a | b2 | DE | CN | DE | CN |
3 | a | b3 | CN | US | CN | US |
4 | a | b4 | US | UK | US | UK |
5 | a | b5 | UK | RS | UK | RS |
You could use a Mapping Load to get what you want. You only get one column to bring back, so that might be a non-starter for you. Here is some dummy data that I think does what you're looking for. Take note of the "Id + 1" term that I've got to create the MappingLoad table
DummyData:
LOAD * Inline
[
'Id','A1', 'B1', 'C1', 'D1'
1, a, b1, IN, DE
2, a, b2, DE, CN
3, a, b3, CN, US
4, a, b4, US, UK
5, a, b5, UK, RS
]
;
DummyMap:
MAPPING LOAD (Id + 1) AS 'IdMappingKey', D1
RESIDENT DummyData
;
DummyData2:
LOAD *,
PEEK(D1,-1) AS 'PEEK(D1,-1))',
ApplyMap('DummyMap', Id, Null()) AS 'MappedLoad'
RESIDENT DummyData
;
DROP TABLE DummyData
;
EXIT Script
;
Hi Justin,
Thanks for the replay, but applymap wont work in my case because , the table actually will be
DummyData:
LOAD * Inline
[
'Id','A1', 'B1', 'C1', 'D1'
1, a, b1, IN, DE
2, a, b2, DE, CN
3, a, b3, CN, US
4, a, b4, US, UK
5, a, b5, UK, RS
1, b, c1, IN, DE
2, b, c2, RN, BM
]
;
output:
PFA