Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help Generating Data. Previous() rowno()

I have following data what i need to do is create new variable for segregating the events in my data for reporting them separately. The new instance will start right after the Movement 7. I want to do this in script as I need to use it in multiple reports and the data size is huge. I hope I am clear with my requirement, if not please ask me what is not clear. I need to do this ASAP.

I have tried to use previous function but failed.

This is the data I have

DeviceDateMovement
A1/10/20141
A1/11/20142
A1/12/20143
A1/13/20144
A1/14/20145
A1/15/20147
A1/16/20143
A1/17/20144
A1/18/20147
A1/19/20141
A1/20/20142
A1/21/20143
A1/22/20144
A1/23/20147
B1/10/20141
B1/11/20142
B1/12/20143
B1/13/20144
B1/14/20147
C1/10/20141
C1/11/20142
C1/12/20143
C1/13/20144
C1/14/20146

This is what I want

DeviceDateMovementNew Field
A1/10/201411
A1/11/201421
A1/12/201431
A1/13/201441
A1/14/201451
A1/15/201471
A1/16/201432
A1/17/201442
A1/18/201472
A1/19/201413
A1/20/201423
A1/21/201433
A1/22/201443
A1/23/201473
B1/10/201411
B1/11/201421
B1/12/201431
B1/13/201441
B1/14/201471
C1/10/201411
C1/11/201421
C1/12/201431
C1/13/201441
C1/14/201461

EXCEL IS ALSO ATTACHED

5 Replies
senpradip007
Specialist III
Specialist III

Try like:

If(RowNo()=1 or Peek(Device) <> Device, 1, If(Peek(Movement)=7, Peek(NewField1)+1, Peek(NewField1)))  AS NewField1

PFA, hope it will help.

Not applicable
Author

It is ignoring the device. For new device number should start from 1

Not applicable
Author

Hi,

Use this script it is working for me. I am also attaching the QVD.

Tab1:

LOAD Device,

     Date,

     Movement

FROM

C:\Users\752202\Downloads\SampleData.xlsx

(ooxml, embedded labels, table is Given);

NoConcatenate

LOAD Device,

     Date,

     Movement,

     if(isnull(Previous(Movement)) or Previous(Device)<>Device,1,if(Previous(Movement)=7,Peek(New_Field)+1,Peek(New_Field))) as New_Field

     Resident Tab1;

    

  DROP Table Tab1;

Hope this helps.

Vivek

Not applicable
Author

Thanks I have got what I wanted

MarcoWedel

Hi,

one solution might be:

QlikCommunity_Thread_137492_Pic1.JPG.jpg

LOAD *,

     If(Device=Previous(Device),Peek([New Field])-(Previous(Movement)=7),1) as [New Field]

FROM [http://community.qlik.com/thread/137492] (html, codepage is 1252, embedded labels, table is @1);

hope this helps

regards

Marco