Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

UPDATE

Hi,

I have created a QV document where I have Following fields

Policy_no, Period_From, Period_to

The policy Number has several records with different periods. I want to find out whether   a particular policy has been renewed in the following month where period should be the immediate next period of the current period.

If policy is renewed the it Should be marked with 'Y'   in a new field 'REN' otherwise 'N'

Could you  please help me in this development in my QV document attached here to

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

This will do it:

Data:

LOAD *,

  Year(PERIOD_FROM)*12 + Month(PERIOD_FROM) As SeqFrom,

  Year(PERIOD_TO)*12 + Month(PERIOD_TO) As SeqTo

;

LOAD POLICY_NO,

     PERIOD_FROM,

     PERIOD_TO

FROM test.xls

(biff, embedded labels);

T1:

LOAD *,

  If(POLICY_NO = Previous(POLICY_NO) And SeqFrom <= Previous(SeqTo)+1, 'Y', 'N') As REN

Resident Data

Order By POLICY_NO, PERIOD_TO;

DROP Table Data;

t1.png

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

3 Replies
settu_periasamy
Master III
Master III

Hi,

May be like this..

T1:
LOAD POLICY_NO,
     Date(PERIOD_FROM) as PERIOD_FROM,
     
Date(PERIOD_TO) as PERIOD_TO
FROM
test.xls
(
biff, embedded labels);
NoConcatenate
T2:
LOAD POLICY_NO,
     
PERIOD_FROM,
     
PERIOD_TO,
     
if(POLICY_NO=PREVIOUS(POLICY_NO),
     
iF(PERIOD_FROM-Previous(PERIOD_TO)=1,'Y','N')) as ren
Resident T1 Order by POLICY_NO,PERIOD_FROM;

DROP Table T1;

jonathandienst
Partner - Champion III
Partner - Champion III

This will do it:

Data:

LOAD *,

  Year(PERIOD_FROM)*12 + Month(PERIOD_FROM) As SeqFrom,

  Year(PERIOD_TO)*12 + Month(PERIOD_TO) As SeqTo

;

LOAD POLICY_NO,

     PERIOD_FROM,

     PERIOD_TO

FROM test.xls

(biff, embedded labels);

T1:

LOAD *,

  If(POLICY_NO = Previous(POLICY_NO) And SeqFrom <= Previous(SeqTo)+1, 'Y', 'N') As REN

Resident Data

Order By POLICY_NO, PERIOD_TO;

DROP Table Data;

t1.png

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
PradeepReddy
Specialist II
Specialist II

Try like this....

Temp:

Load Policyno,

  Period_From,

  Period_To

From Source;

Final:

Load *,

  if(peek(Policyno)=Policyno and addmonths(peek(Period_From),-12)=Period_From,'Y','N') as Ren

resident Temp order by Policyno asc,Period_From desc;

Drop table Temp;