Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

ziabobaz
Contributor III

Number the occurence of the field value in the script

Screenshot_1.jpg

I have a table with Date and Item, sorted asc by Date

I need to put the number of occurence of the Item, as on the picture.

Please, help, I am stuck.

 

Labels (1)
1 Solution

Accepted Solutions
Highlighted
PV
New Contributor II

Re: Number the occurence of the field value in the script

Order(Asc) your data by Date and Item and derive the occurrence column as below.
if(Peek(Item)=Item, Peek(Occurrence)+1,1) as Occurrence
4 Replies

Re: Number the occurence of the field value in the script

d seems to be appearing for the first time, why is the occurrence column showing 4?

image.png

ziabobaz
Contributor III

Re: Number the occurence of the field value in the script

sorry, my mistake

D is '1'

Highlighted
PV
New Contributor II

Re: Number the occurence of the field value in the script

Order(Asc) your data by Date and Item and derive the occurrence column as below.
if(Peek(Item)=Item, Peek(Occurrence)+1,1) as Occurrence
ziabobaz
Contributor III

Re: Number the occurence of the field value in the script

Ordered by Item, then Date - it worked, thank you!