Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
engaug87
New Contributor III

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

Tags (1)
1 Solution

Accepted Solutions

Re: Unique Sequence Number

May be this?

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
5 Replies

Re: Unique Sequence Number

May be this?

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
engaug87
New Contributor III

Re: Unique Sequence Number

Hi Anil,

Please tell me how it is working Autonumber()?

AutoNumber(RecNo(),Tproduct)

Why this line of code is generating unique number.

Thanks,

Re: Unique Sequence Number

Have a look autonumber  - script function ‒ QlikView

Autonumber(), Recno(), rowno()

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
engaug87
New Contributor III

Re: Unique Sequence Number

Hi Anil,

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

Thanks,

Re: Unique Sequence Number

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)