Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Autonumber, adding numbers to Rows etc

Hi,

I have the below field containing the below data;

156489

156489

156489

156789

156789

156789

156789

156789

158978

I need the script to generate a number for each order number, but start a new sequence once it reaches a new Order.

Example below:

  

WHOSequence
156489 1
1564892
1564893
1567891
1567892
1567893
1567894
1567895
1589781

Please can someone assist?

Thanks in Advance

6 Replies
sunny_talwar

May be this:

LOAD WHO,

     AutoNumber(RowNo(), WHO) as Sequence

FROM ....;

Anil_Babu_Samineni

May be use this?

LOAD *, AutoNumber(rowno(),FieldName) as Row Inline [

FieldName

156489

156489

156489

156789

156789

156789

156789

156789

158978

];

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
sunny_talwar

Or this:

Table:

LOAD WHO

FROM....

FinalTable:

LOAD WHO,

     If(WHO = Previous(WHO), RangeSum(Peek('Sequence'), 1), 1) as Sequence

Resident Table

Order by WHO;

This option will give better performance for a larger dataset

ahaahaaha
Partner - Master
Partner - Master

Hi Ruan,

Table1:

LOAD*Inline

[WHO

156489

156489

156489

156789

156789

156789

156789

156789

158978

];

Left Join

LOAD*,

If(Previous(WHO) = WHO, Rangesum(1, peek('Sequence')), 1) as Sequence

Resident Table1;

Result

10.jpg

Regards,

Andrey

Anonymous
Not applicable
Author

Thanks This worked ! You Champion

Anil_Babu_Samineni

Good, You may close this thread by flag Correct answer. Hope Sunny's 2 solutions should work. But, I don't know how your data seems. Any how some what Left Join works for you

Close this thread, Please

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