Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for 
Search instead for 
Did you mean: 
angel2605
Contributor III
Contributor III

id Generator

good afternoon I need your help ... I want to create QlikView id for each change me the name of a program I get a different id ... annex an example of what I want to do qlikview ...

1 power rangers
2 Today
2 Today
2 Today
3 SpongeBob
4 Sylvester & Tweety Mysteries
5 today
5 today


what I need is that each change the program assigned me a new id

1 Solution

Accepted Solutions
sunny_talwar

I did find my mistake, but handled it a little differently with Alt function. But I do like RangeSum solution, much more elegant. Thanks for sharing

Alt(If(Peek('Program') = Program, Peek('ID'), Peek('ID') + 1), 1) as ID

View solution in original post

6 Replies
sunny_talwar

Try this:

LOAD Program,

          If(Peek('Program') = Program, Peek('ID'), Peek('ID') + 1) as ID

FROM Source


LOAD Program,

          Alt(If(Peek('Program') = Program, Peek('ID'), Peek('ID') + 1), 1) as ID

FROM Source

sunny_talwar

Attaching a sample. Script:

Table:

LOAD * Inline [

Program

power rangers

Today

Today

Today

SpongeBob

Sylvester & Tweety Mysteries

today

today

];

NewTable:

LOAD RowNo() as [Row Number],

  Program,

  Alt(If(Peek('Program') = Program, Peek('ID'), Peek('ID') + 1), 1) as ID

Resident Table;

Output

Capture.PNG

Row Number is added just to show that you have Today showing up thrice, otherwise table box would have just showed it once.

HTH

Best,

Sunny

Henric_Cronström

sunindia

Almost right. However, Peek('ID') will return NULL on the first row and since NULL + 1 => NULL, it will not work.

Try this instead:

LOAD Program,

          If(Peek('Program') = Program, Peek('ID'), RangeSum(Peek('ID'), 1)) as ID

FROM Source


HIC

sunny_talwar

I did find my mistake, but handled it a little differently with Alt function. But I do like RangeSum solution, much more elegant. Thanks for sharing

Alt(If(Peek('Program') = Program, Peek('ID'), Peek('ID') + 1), 1) as ID

View solution in original post

angel2605
Contributor III
Contributor III
Author

thank you very much was very useful help your greetings    

luis espinoza

angel2605
Contributor III
Contributor III
Author

thank you