Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

Announcements
Register for Events and Webinars directly from Qlik Community: http://bit.ly/2Vpnenx
Highlighted
Not applicable

Generate a key with previous or peek function

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?

1 Solution

Accepted Solutions
Highlighted
MVP & Luminary
MVP & Luminary

Re: Generate a key with previous or peek function

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


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Highlighted
MVP & Luminary
MVP & Luminary

Re: Generate a key with previous or peek function

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


talk is cheap, supply exceeds demand

View solution in original post

Highlighted
Not applicable

Re: Generate a key with previous or peek function

Wow, thank you!