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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
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