# New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Partner

## N-2 row for each records in same dimension

Hi Expert,

Here i want n-2 row for all distinct claim wise SrNo.below are given some sample cases.

OUTPUT--

Claim --  SrNo

C1 -- 5

C2 --  4

T2:

Claim, SrNo,date

C1, 1, 01-02-2018

C1,2,01-02-2018

C1,3,04-02-2018

C1,4,05-02-2018

C1,5,04-04-2018

C1,6,03-07-2018

C2,1,01-02-2018

C2,2,11-02-2018

C2,4,19-02-2018

C2,7,15-06-2018

];

I have used below script for claim C1 its given correct value but for C2 onwards values are getting wrong.

T3:

if(Claim=Peek(Claim),SrNo,Peek('SrNo',-2)) AS Sr1

Resident T2

Order by Claim;

1 Solution

Accepted Solutions
MVP

## Re: N-2 row for each records in same dimension

Try this

T2:

Claim, SrNo, date

C1, 1, 01-02-2018

C1, 2, 01-02-2018

C1, 3, 04-02-2018

C1, 4, 05-02-2018

C1, 5, 04-04-2018

C1, 6, 03-07-2018

C2, 1, 01-02-2018

C2, 2, 11-02-2018

C2, 4, 19-02-2018

C2, 7, 15-06-2018

];

Left Join (T2)

FirstSortedValue(SrNo, -date, 2) as Sr1

Resident T2

Group By Claim;

MVP

## Re: N-2 row for each records in same dimension

Try this

T2:

Claim, SrNo, date

C1, 1, 01-02-2018

C1, 2, 01-02-2018

C1, 3, 04-02-2018

C1, 4, 05-02-2018

C1, 5, 04-04-2018

C1, 6, 03-07-2018

C2, 1, 01-02-2018

C2, 2, 11-02-2018

C2, 4, 19-02-2018

C2, 7, 15-06-2018

];

Left Join (T2)