Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sunilkumarqv
Specialist II
Specialist II

Autogenarate Numbers

     Hi need to auto generate ids based on the numbers like

Examples

slno, num, Autogerate

1,        1 ,       1

2,        1,        2

3,        23,     1

4,        23,     2

5,        23,     3

6,        23,     4

7,        12,     1

8,        12,     2

9,        15,     1

If u noticed autogerate column

for first two common numbers 1,2 and next 3 to 6  slno should repeated numbers 1,2... similarly so on , im wondering ill get any help

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Easier way should be like:

Load

          slno,

          num,

          Autonumber(slno,num) as AutoGenSeq

...

View solution in original post

3 Replies
ali_hijazi
Partner - Master II
Partner - Master II

temp:

load slno, num

resident your table order by num asc;

load * , if (rowNo() = 1 or num<> previous(num),1,peek(Autognerate) + 1) as AutoGenerate

resident temp;

drop table temp;

I can walk on water when it freezes
its_anandrjs
Champion III
Champion III

Hi,

Try this ways

LOAD

slno, num, Autogerate,

if(num = Previous(num),Peek(Num)+1,1 ) as AutogerateNew;

LOAD * INLINE [

    slno, num, Autogerate

    1, 1, 1

    2, 1, 2

    3, 23, 1

    4, 23, 2

    5, 23, 3

    6, 23, 4

    7, 12, 1

    8, 12, 2

    9, 15, 1

];

And you get this table fields

autogennum.png

Regards

Anand

tresesco
MVP
MVP

Easier way should be like:

Load

          slno,

          num,

          Autonumber(slno,num) as AutoGenSeq

...