Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Unique Sequence Number

Hi,

Please check given below required input table and required output table. I am looking for solution which must generate unique record number for each record but whenver Tproduct change or new one come then Titem number must reset and start from 1.

  

Required Input
TproductTitem
P1T1
P1T2
P1T1
P1T3
P1T4
P1T2
P1T1
P2T1
P2T2
P2T1
P2T3
P3T4
P3T2
P3T1

--------------------------------------------------

 

Required Output
Unique IDTproductTitem
P1-T1P1T1
P1-T2P1T2
P1-T3P1T1
P1-T4P1T3
P1-T5P1T4
P1-T6P1T2
P1-T7P1T1
P2-T1P2T1
P2-T2P2T2
P2-T3P2T1
P2-T4P2T3
P3-T1P3T4
P3-T2P3T2
P3-T3P3T1

Thanks

1 Solution

Accepted Solutions
Anil_Babu_Samineni

May be this?

Tproduct & '-' & Left(Titem,1) & AutoNumber(RecNo(),Tproduct) as [Unique ID]

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

5 Replies
Anil_Babu_Samineni

May be this?

Tproduct & '-' & Left(Titem,1) & AutoNumber(RecNo(),Tproduct) as [Unique ID]

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

Hi Anil,

Please tell me how it is working Autonumber()?

AutoNumber(RecNo(),Tproduct)

Why this line of code is generating unique number.

Thanks,

Anil_Babu_Samineni

Have a look autonumber  - script function ‒ QlikView

Autonumber(), Recno(), rowno()

Note - If applicable, please close this thread or ask if still not resolved.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

Hi Anil,

I would like to know technically, How it is working?

Thanks,

Anil_Babu_Samineni

In fact, I believe sujjeth gave with some screenshots. I am not a good tutor to explain. Some how?

Tproduct & '-' & Left(Titem,1) & AutoNumber(RecNo(),Tproduct) as [Unique ID]


Let's bifurcate to each what actually doing here is

Tproduct & '-' & Left(Titem,1) returns

Tproduct          Titem          Output

P1                      T1            P1-T

AutoNumber(RecNo(),Tproduct)

For "Tproduct" unique rows it will generate the sequence numbers till row got changed from 1 to total sequence rows of each unique. That is how "Autogenerate" works for "AutoNumber". Instead of asking, Why can't you think by yourself to understand the sequence

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful