Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Autonumber in expression

Hi All,

within an expression I need to autonumerate rows in a way that new Name restarts counter

Name, Number

John, 1

John, 2

Mary, 1

John, 3

Mary, 2

Any idea?

Regards,

Przemek

3 Replies
Not applicable
Author

Hi,

use the example code below

Temp1:

LOAD * INLINE [

name

John

John

Mary

John

Mary

];

Regards

Przemek

Tab:

NoConcatenate

LOAD

name,

IF (peek('name')<>name,1, peek('counter')+1) AS counter

RESIDENT Temp1

order by name;

drop table Temp1;

Not applicable
Author

Hi Przemek 🙂

thanks for the reply. The problem, however, is that I need to have it built within an expression not script.

Regards,

Przemek

Not applicable
Author

You could use similar approach, however that would only work when the names are sorted.

I can't think of a possible workaround at the moment (without having the names sorted).

Regards

Przemek