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: 
francisvandergr
Partner - Creator II
Partner - Creator II

Rowno per order

I have included a script.

I like to have for each order a rowno() starting for every order with 1

Can someone help me with this script.

See the example

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You can use autonumber() to get a rowno in the script:

ORDERS:

LOAD *, AutoNumber(recno(), Orderno) as rowno INLINE [

    Orderno, Article, Qty, Amount

    100, 1, 1, 10

    120, 2, 1, 11

    130, 2, 2, 66

    150, 3, 3, 33

    100, 2, 1, 2

    120, 4, 50, 100

    150, 3, 40, 80

    150, 3, 50, 70

];

You can sort your input table differently if you need a special sort order for rowno.

edit:

For example like

ORDERS:

LOAD * INLINE [

    Orderno, Article, Qty, Amount

    100, 1, 1, 10

    120, 2, 1, 11

    130, 2, 2, 66

    150, 3, 3, 33

    100, 2, 1, 2

    120, 4, 50, 100

    150, 3, 40, 80

    150, 3, 50, 70

];

LOAD *, AutoNumber(recno(), Orderno) as rowno

Resident ORDERS

ORDER BY Amount;

DROP TABLE ORDERS;

View solution in original post

4 Replies
sunny_talwar

Try this:

ORDERS:

LOAD *,

  AutoNumber(RowNo(), Orderno) as RowNo;

LOAD * INLINE [

    Orderno, Article, Qty, Amount

    100, 1, 1, 10

    120, 2, 1, 11

    130, 2, 2, 66

    150, 3, 3, 33

    100, 2, 1, 2

    120, 4, 50, 100

    150, 3, 40, 80

    150, 3, 50, 70

];

Capture.PNG

swuehl
MVP
MVP

You can use autonumber() to get a rowno in the script:

ORDERS:

LOAD *, AutoNumber(recno(), Orderno) as rowno INLINE [

    Orderno, Article, Qty, Amount

    100, 1, 1, 10

    120, 2, 1, 11

    130, 2, 2, 66

    150, 3, 3, 33

    100, 2, 1, 2

    120, 4, 50, 100

    150, 3, 40, 80

    150, 3, 50, 70

];

You can sort your input table differently if you need a special sort order for rowno.

edit:

For example like

ORDERS:

LOAD * INLINE [

    Orderno, Article, Qty, Amount

    100, 1, 1, 10

    120, 2, 1, 11

    130, 2, 2, 66

    150, 3, 3, 33

    100, 2, 1, 2

    120, 4, 50, 100

    150, 3, 40, 80

    150, 3, 50, 70

];

LOAD *, AutoNumber(recno(), Orderno) as rowno

Resident ORDERS

ORDER BY Amount;

DROP TABLE ORDERS;

Kushal_Chawda

another way

Data:

LOAD *

FROM Table.qvd(qvd);

new:

noconcatenate

LOAD *,

           if(rowno()=1 or Orderno<>previous(Orderno),1,peek('Rowno')+1) as Rowno

Resident Data

order by Orderno;

drop table Data;

sunny_talwar

I guess my solution was not as helpful as others

But I am glad you were able to resolve your issue

Best,

Sunny