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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Assign serial number after sorting

Hi,

I want to sort the column and then assign serial number

example I want to sort below data based on LOCN and then assign serial number, expected data shown below

Data:

 

LOCNRTN
1A1A1023
1B2A4231
1A1A1028
1A2A3289
1B3A1628
1A3A3290
1A4A2111
1A2A3123
1A4A2312
1B1A4421
1A2A3124
1B1B1245
1B1B1287
1A1A1027
1B2B7652

Expected Data:

  

Serial NoLOCNRTN
11A1A1023
21A1A1027
31A1A1028
41A2A3123
51A2A3124
61A2A3289
71A3A3290
81A4A2111
91A4A2312
101B1A4421
111B1B1245
121B1B1287
131B2A4231
141B2B7652
151B3A1628
4 Replies
tresesco
MVP
MVP

Try like:

Data:

Load * Inline [

LOCN RTN

1A1A 1023

1B2A 4231

1A1A 1028

1A2A 3289

1B3A 1628

1A3A 3290

1A4A 2111

1A2A 3123

1A4A 2312

1B1A 4421

1A2A 3124

1B1B 1245

1B1B 1287

1A1A 1027

1B2B 7652] (delimiter is '\t');

Final:

Load

  RowNo() as [Serial No],

  *

Resident Data  order by LOCN;

DROP Table Data;



susovan
Partner - Specialist
Partner - Specialist

You also try this,

Table1:

LOAD * INLINE [

LOCN,RTN

1A1A,1023

1B2A,4231

1A1A,1028

1A2A,3289

1B3A,1628

1A3A,3290

1A4A,2111

1A2A,3123

1A4A,2312

1B1A,4421

1A2A,3124

1B1B,1245

1B1B,1287

1A1A,1027

1B2B,7652 ];

left join

Table2:

LOAD *,

RowNo() as Sr.no

Resident Table1 Order by LOCN;

Warm Regards,
Susovan
Anonymous
Not applicable
Author

Hi Vibhu,

Use this code if you want same Serial Number for Locn field

Left Join (YourTable)

LOAD *,

    AutoNumber(LOCN) as Serial

RESIDENT YourTable

ORDER BY LOCN ASC;

If you want one serial number for each row:

Left Join (YourTable)

LOAD *,

   RowNo() as Serial

RESIDENT YourTable

ORDER BY LOCN ASC;

If you want one serial number for each combination of Locn and Rtn:

Left Join (YourTable)

LOAD *,

   Autonumber(LOCN&'-'&RTN) as Serial

RESIDENT YourTable

ORDER BY LOCN ASC, RTN ASC;

Regards!!

antoniotiman
Master III
Master III

Hi Vibhu,

Temp

LOAD * From Table;

Load *,

RowNo() as SerialNo

Resident Temp

Order By LOCN,RTN;

Drop Table Temp;

Regards,

Antonio