Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Community,
I want a key, that will be generate from the first and second column.
it is important that "Col2" has the order 1,2,3,4,1,2,3,4.
The first four values are "Key_1" and the last four values from the "Col2" are "Key_2".
How can i generate the key with the previous or peek function?
has anyone an idea?
This should work if I understand what you want correctly:
LOAD *, 'Key_' & Counter as GeneratedKey;
LOAD *, if(previous(Col2)>Col2,rangesum(1,peek(Counter)),rangemax(1,peek(Counter))) as Counter;
LOAD * INLINE [
Sample, Col2, GenerateKey , Value
A, 1,Key_1,10
A, 2 ,Key_1,20
A, 3 ,Key_1,15
A, 4 ,Key_1,30
A, 1,Key_2,20
A, 2,Key_2,30
A, 3 ,Key_2,40
A, 4 ,Key_2,50
];
Compare GeneratedKey with your field GenerateKey
This should work if I understand what you want correctly:
LOAD *, 'Key_' & Counter as GeneratedKey;
LOAD *, if(previous(Col2)>Col2,rangesum(1,peek(Counter)),rangemax(1,peek(Counter))) as Counter;
LOAD * INLINE [
Sample, Col2, GenerateKey , Value
A, 1,Key_1,10
A, 2 ,Key_1,20
A, 3 ,Key_1,15
A, 4 ,Key_1,30
A, 1,Key_2,20
A, 2,Key_2,30
A, 3 ,Key_2,40
A, 4 ,Key_2,50
];
Compare GeneratedKey with your field GenerateKey
Wow, thank you!