Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using peek or for loop

Hello,

I have a table with 2 ID columns ID1 and ID2.

As you can see there can be 2 ID2 for same ID1.

Column ProjectID has a numbering based on the unique ID1.

Im having trouble having a sub numbering for ID2. I don't know if I have to use peek function or a for loop.

If there are 2 ID2 for ID1, I need a new column which indicates sub rank 1,2.

If there is 1 ID2 for ID1, I need to display 1 if there are 3 ID2 grouped under ID 1, I need to have a numbering 1,2,3

Any help on this would be appreciated.

Thank you!

1 Solution

Accepted Solutions
tresesco
MVP
MVP

If you are numbering the combinations (ID1 and ID2), try like:

Autonumber(ID2, ID1) as Counter

View solution in original post

11 Replies
Not applicable
Author

Not applicable
Author

I'm able to add a total count of the sub id, but able to to a numbering...

Not applicable
Author

Or do I have to use a pick() function?

tresesco
MVP
MVP

Try like:

Autonumber(Rowno(), ID1) as Counter

Edit: Corrected

Not applicable
Author

Ah! i thought it nearly worked, but noit's not numbering correctly...

sunilkumarqv
Specialist II
Specialist II

autonumber(ID1,ID2) as NewID

from datasource;

or

autonumber(ID2,ID1) as NewID

from datasource;

Not applicable
Author

Hi Hero,

If you just need to create a new id for each ID2 grouped by ID1, you could try autonumber(ID2,'ID_Inc' & ID1) as ID2_PK


sunilkumarqv
Specialist II
Specialist II

@check the file

tresesco
MVP
MVP

If you are numbering the combinations (ID1 and ID2), try like:

Autonumber(ID2, ID1) as Counter