Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Restart autonumber count every....X

Howdy,

I'm building a dashboard to analyze the Sessions_Servername log file.

I want to restart my autonumber counter every Day for each user...So each user will have X # of sessions for each day, then it will restart the next day.

Sample output:

User,       Date,       Autonumber(???)

David,    1/1/2014,  1

David     1/1/2014,  2

David     1/1/2014,  3

David     1/2/2014,  1

David     1/2/2014,  2

David     1/2/2014,  3

David     1/2/2014,  4



Much thanks,


-David

1 Solution

Accepted Solutions
MVP
MVP

Re: Restart autonumber count every....X

RESULT

1.png


SCRIPT

a:

load User, Date inline [

User,      Date,      Autonumber

David,    1/1/2014,  1

David ,    1/1/2014,  2

David ,    1/1/2014,  3

David ,    1/2/2014,  1

David ,    1/2/2014,  2

David ,    1/2/2014,  3

David ,    1/2/2014,  4

Simon,    1/1/2014,  1

Simon ,    1/1/2014,  2

Simon ,    1/1/2014,  3

Simon ,    1/2/2014,  1

Simon ,    1/2/2014,  2

Simon ,    1/2/2014,  3

Simon ,    1/2/2014,  4

];

b:

NoConcatenate

load *,

if(User<>peek(User) or Date<>Peek(Date), 1, peek(id)+1) as id

Resident a

order by User, Date;

DROP Table a;

2 Replies
MVP
MVP

Re: Restart autonumber count every....X

RESULT

1.png


SCRIPT

a:

load User, Date inline [

User,      Date,      Autonumber

David,    1/1/2014,  1

David ,    1/1/2014,  2

David ,    1/1/2014,  3

David ,    1/2/2014,  1

David ,    1/2/2014,  2

David ,    1/2/2014,  3

David ,    1/2/2014,  4

Simon,    1/1/2014,  1

Simon ,    1/1/2014,  2

Simon ,    1/1/2014,  3

Simon ,    1/2/2014,  1

Simon ,    1/2/2014,  2

Simon ,    1/2/2014,  3

Simon ,    1/2/2014,  4

];

b:

NoConcatenate

load *,

if(User<>peek(User) or Date<>Peek(Date), 1, peek(id)+1) as id

Resident a

order by User, Date;

DROP Table a;

anbu1984
Honored Contributor III

Re: Restart autonumber count every....X

Load *,AutoNumber(RecNo(),Date) Inline [

User,Date

David,1/1/2014

David,1/1/2014

David,1/1/2014

David,1/2/2014

David,1/2/2014

David,1/2/2014

David,1/2/2014 ];

Community Browser