Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

seq_no

Hi,

I have following data(POLICY_NO AND PERIOD_FROM columns)  in my document I want to create a third column of data with SEQ_NO based on the YEAR(PERIOD_FROM )  for each POLICY_NO in data load script  as I have shown in my sample in red

   

POLICY_NOPERIOD_FROM SEQ_NO
NI00111C00003910-Feb-20121
NI00111C00003910-Feb-20132
NI00111C00003910-Feb-20143
NI00121F00001406-Mar-20121
NI00121F00001406-Mar-20132
NI00121F00001406-Mar-20143
NI00121F00001406-Mar-20154
NI00144F000009827-Sep-20141
NI00144F000009805-Oct-20152
NI00121C00006718-May-20121
NI00121C00006718-May-20132
NI00121C00006718-May-20143
NI00121C00006718-May-20154

Pls help me with script

1 Solution

Accepted Solutions
sunny_talwar

You need ascending order? Try this:

LOAD

BCOD,

CLA_CODE,

CLAIM_NO,

CUS_TYPE,

LOSS_DATE,

NEW_REN,

PAID_AMOUNT,

PERIOD_FROM,

PERIOD_TO,

POLICY_NO,

PRD_CODE,

PREMIUM,

REN,

YEAR,

If(POLICY_NO = Peek('POLICY_NO'), Peek('LAST_REN_YEAR'), LAST_REN_YEAR) as LAST_REN_YEAR,

If(POLICY_NO = Peek('POLICY_NO'), RangeSum(Peek('SEQ_NO'), 1), 1) as SEQ_NO

Resident FINAL_DATA

Order By POLICY_NO, PERIOD_FROM asc;

View solution in original post

5 Replies
sunny_talwar

Try this:

Table:

LOAD * Inline [

POLICY_NO, PERIOD_FROM

NI00111C000039, 10-Feb-2012

NI00111C000039, 10-Feb-2013

NI00111C000039, 10-Feb-2014

NI00121F000014, 06-Mar-2012

NI00121F000014, 06-Mar-2013

NI00121F000014, 06-Mar-2014

NI00121F000014, 06-Mar-2015

NI00144F0000098, 27-Sep-2014

NI00144F0000098, 05-Oct-2015

NI00121C000067, 18-May-2012

NI00121C000067, 18-May-2013

NI00121C000067, 18-May-2014

NI00121C000067, 18-May-2015

];

FinalTable:

LOAD *,

  If(POLICY_NO = Peek('POLICY_NO'), RangeSum(Peek('SEQ_NO'), 1), 1) as SEQ_NO

Resident Table

Order By POLICY_NO, PERIOD_FROM;

DROP Table Table;


Capture.PNG

upaliwije
Creator II
Creator II
Author

Thanks Sunny

It is working with a bit of problem my output is as follows

CYEARPERIOD_FROMPERIOD_TONEW_RENLAST_REN_YEARSEQ_NO
NI00111C000039201210-Feb-201209-Feb-2013REN20143
NI00111C000039201310-Feb-201309-Feb-2014REN20142
NI00111C000039201410-Feb-201409-Feb-2015REN20141
NI00121F000014201206-Mar-201205-Mar-2013NEW20154
NI00121F000014201306-Mar-201305-Mar-2014REN20153
NI00121F000014201406-Mar-201405-Mar-2015REN20152
NI00121F000014201506-Mar-201505-Mar-2016REN20151
NI00144F0000098201427-Sep-201426-Sep-2015NEW20152
NI00144F0000098201505-Oct-201504-Oct-2016REN20151
NI00141H0000032201410-Nov-201409-Nov-2015NEW20152
NI00141H0000032201510-Nov-201509-Nov-2016REN20151

Seq No is in descending order.

My script is as follows

LOAD

BCOD,

CLA_CODE,

CLAIM_NO,

CUS_TYPE,

LOSS_DATE,

NEW_REN,

PAID_AMOUNT,

PERIOD_FROM,

PERIOD_TO,

POLICY_NO,

PRD_CODE,

PREMIUM,

REN,

YEAR,

If(POLICY_NO = Peek('POLICY_NO'), Peek('LAST_REN_YEAR'), LAST_REN_YEAR) as LAST_REN_YEAR,

If(POLICY_NO = Peek('POLICY_NO'), RangeSum(Peek('SEQ_NO'), 1), 1) as SEQ_NO

Resident FINAL_DATA

Order By POLICY_NO,PERIOD_FROM desc;

Kindly correct me

Pls also let me know how this rangesum function works

sunny_talwar

You need ascending order? Try this:

LOAD

BCOD,

CLA_CODE,

CLAIM_NO,

CUS_TYPE,

LOSS_DATE,

NEW_REN,

PAID_AMOUNT,

PERIOD_FROM,

PERIOD_TO,

POLICY_NO,

PRD_CODE,

PREMIUM,

REN,

YEAR,

If(POLICY_NO = Peek('POLICY_NO'), Peek('LAST_REN_YEAR'), LAST_REN_YEAR) as LAST_REN_YEAR,

If(POLICY_NO = Peek('POLICY_NO'), RangeSum(Peek('SEQ_NO'), 1), 1) as SEQ_NO

Resident FINAL_DATA

Order By POLICY_NO, PERIOD_FROM asc;

maxgro
MVP
MVP

Table:

LOAD * Inline [

POLICY_NO, PERIOD_FROM

NI00111C000039, 10-Feb-2012

NI00111C000039, 10-Feb-2013

NI00111C000039, 10-Feb-2014

NI00121F000014, 06-Mar-2012

NI00121F000014, 06-Mar-2013

NI00121F000014, 06-Mar-2014

NI00121F000014, 06-Mar-2015

NI00144F0000098, 27-Sep-2014

NI00144F0000098, 05-Oct-2015

NI00121C000067, 18-May-2012

NI00121C000067, 18-May-2013

NI00121C000067, 18-May-2014

NI00121C000067, 18-May-2015

];

FinalTable:

LOAD

  *,

  AutoNumber(Right(PERIOD_FROM,4),POLICY_NO) as SEQ_NO

Resident Table

Order By POLICY_NO, PERIOD_FROM;

DROP Table Table;

HirisH_V7
Master
Master

Hi,

check this,

Temp:

LOAD * ,

AutoNumber(Num(Date(Date#(PERIOD_FROM,'DD-MMM-YYYY'),'DD/MM/YYYY')),POLICY_NO) as SEQ_NO,

Num(Date(Date#(PERIOD_FROM,'DD-MMM-YYYY'),'DD/MM/YYYY')) as DateNum

INLINE [

    POLICY_NO, PERIOD_FROM

    NI00111C000039, 10-Feb-2012

    NI00111C000039, 10-Feb-2013

    NI00111C000039, 10-Feb-2014

    NI00121F000014, 06-Mar-2012

    NI00121F000014, 06-Mar-2013

    NI00121F000014, 06-Mar-2014

    NI00121F000014, 06-Mar-2015

    NI00144F0000098, 27-Sep-2014

    NI00144F0000098, 05-Oct-2015

    NI00121C000067, 18-May-2012

    NI00121C000067, 18-May-2013

    NI00121C000067, 18-May-2014

    NI00121C000067, 18-May-2015

];

Table:

LOAD *

Resident Temp Order by POLICY_NO,SEQ_NO asc;

Output:

Seqno Columns-208288.PNG

HTH,

PFA,

Hirish

HirisH
“Aspire to Inspire before we Expire!”