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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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

Labels (1)
6 Replies
sunny_talwar
MVP
MVP

May be this:

LOAD WHO,

     AutoNumber(RowNo(), WHO) as Sequence

FROM ....;

Anil_Babu_Samineni
MVP
MVP

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
MVP
MVP

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
MVP
MVP

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