Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
upaliwije
Creator II
Creator II

PIVOT TABLE

Hi Friends

I am doing an analysis of Insurance related data and sample of my data is given below

POLICY_NOYEARPERIOD_FROMPERIOD_TONEW_RENPREMIUM
NI00111C000039201210-Feb-201209-Feb-2013REN18,212
NI00111C000039201310-Feb-201309-Feb-2014REN17,372
NI00111C000039201410-Feb-201409-Feb-2015REN16,278
NI00131A000028201313-May-201312-May-2014NEW59,793
NI00131A000028201413-May-201412-May-2015REN29,782
NI00141A0000041201406-Oct-201405-Oct-2015NEW28,311
NI00141A0000041201506-Oct-201505-Oct-2016REN27,205
NI00121F000014201206-Mar-201205-Mar-2013NEW13,969
NI00121F000014201306-Mar-201305-Mar-2014REN12,728
NI00121F000014201406-Mar-201405-Mar-2015REN11,885
NI00121F000014201506-Mar-201505-Mar-2016REN11,619
NI00111D000019201231-May-201230-May-2013REN72,310
NI00111D000019201331-May-201330-May-2014REN69,927
NI00141C0000106201413-Oct-201412-Oct-2015NEW35,030
NI00141C0000106201513-Oct-201512-Oct-2016REN33,205
NI00121D000053201223-May-201222-May-2013NEW39,059
NI00121D000053201323-May-201322-May-2014REN35,262

I want to summaries these policies into a table shown below

YEAR2012201320142015
2012NEW2
REN2421
2013NEW1
REN1
2014NEW2
REN2
2015NEW
REN 
4553

If I am to explain my requirement

4 polices done in 2012 come under  2 New and 2 Renewal 

Those 4  are renewed in 2013 and 1 new policy done in 2013

Out of 4 policies done in 2012 only 2 are renewed in 2014 and 1  in 2015

2 new policies are done in 2014 and 1 policy is renewed from 2013

..................

Hope you understand my requirement.

Kindly help me to tabulate above Requirement in QV document. Appreciate  If sample QV doc  is attched

Labels (1)
1 Solution

Accepted Solutions
Kushal_Chawda

Data:

LOAD * Inline [

POLICY_NO,    YEAR,    PERIOD_FROM,    PERIOD_TO,    NEW_REN,    PREMIUM

NI00111C000039,    2012,    10-Feb-2012,    09-Feb-2013,    REN,    18,212

NI00111C000039,    2013,    10-Feb-2013,    09-Feb-2014,    REN,    17,372

NI00111C000039,    2014,    10-Feb-2014,    09-Feb-2015,    REN,    16,278

NI00131A000028,    2013,    13-May-2013,    12-May-2014,    NEW,    59,793

NI00131A000028,    2014,    13-May-2014,    12-May-2015,    REN,    29,782

NI00141A0000041,    2014,    06-Oct-2014,    05-Oct-2015,    NEW,    28,311

NI00141A0000041,    2015,    06-Oct-2015,    05-Oct-2016,    REN,    27,205

NI00121F000014,    2012,    06-Mar-2012,    05-Mar-2013,    NEW,    13,969

NI00121F000014,    2013,    06-Mar-2013,    05-Mar-2014,    REN,    12,728

NI00121F000014,    2014,    06-Mar-2014,    05-Mar-2015,    REN,    11,885

NI00121F000014,    2015,    06-Mar-2015,    05-Mar-2016,    REN,    11,619

NI00111D000019,    2012,    31-May-2012,    30-May-2013,    REN,    72,310

NI00111D000019,    2013,    31-May-2013,    30-May-2014,    REN,    69,927

NI00141C0000106,    2014,    13-Oct-2014,    12-Oct-2015,    NEW    ,35,030

NI00141C0000106,    2015,    13-Oct-2015,    12-Oct-2016,    REN,    33,205

NI00121D000053,    2012,    23-May-2012,    22-May-2013,    NEW,    39,059

NI00121D000053,    2013,    23-May-2013,    22-May-2014,    REN,    35,262 ];

New:

NoConcatenate

LOAD *,

if((RowNo()=1 or POLICY_NO<>Previous(POLICY_NO)) ,YEAR,

if(POLICY_NO=Previous(POLICY_NO) , Peek('YEAR1'))) as YEAR1

Resident Data

Order by POLICY_NO,YEAR asc;

DROP Table Data;



Create Pivot Table

Dimensions:

YEAR1,

NEW_REN,

YEAR


Expression:

Count(POLICY_NO)


View solution in original post

8 Replies
shamitshah
Partner - Creator
Partner - Creator

Please see attached.

Kushal_Chawda

Data:

LOAD * Inline [

POLICY_NO,    YEAR,    PERIOD_FROM,    PERIOD_TO,    NEW_REN,    PREMIUM

NI00111C000039,    2012,    10-Feb-2012,    09-Feb-2013,    REN,    18,212

NI00111C000039,    2013,    10-Feb-2013,    09-Feb-2014,    REN,    17,372

NI00111C000039,    2014,    10-Feb-2014,    09-Feb-2015,    REN,    16,278

NI00131A000028,    2013,    13-May-2013,    12-May-2014,    NEW,    59,793

NI00131A000028,    2014,    13-May-2014,    12-May-2015,    REN,    29,782

NI00141A0000041,    2014,    06-Oct-2014,    05-Oct-2015,    NEW,    28,311

NI00141A0000041,    2015,    06-Oct-2015,    05-Oct-2016,    REN,    27,205

NI00121F000014,    2012,    06-Mar-2012,    05-Mar-2013,    NEW,    13,969

NI00121F000014,    2013,    06-Mar-2013,    05-Mar-2014,    REN,    12,728

NI00121F000014,    2014,    06-Mar-2014,    05-Mar-2015,    REN,    11,885

NI00121F000014,    2015,    06-Mar-2015,    05-Mar-2016,    REN,    11,619

NI00111D000019,    2012,    31-May-2012,    30-May-2013,    REN,    72,310

NI00111D000019,    2013,    31-May-2013,    30-May-2014,    REN,    69,927

NI00141C0000106,    2014,    13-Oct-2014,    12-Oct-2015,    NEW    ,35,030

NI00141C0000106,    2015,    13-Oct-2015,    12-Oct-2016,    REN,    33,205

NI00121D000053,    2012,    23-May-2012,    22-May-2013,    NEW,    39,059

NI00121D000053,    2013,    23-May-2013,    22-May-2014,    REN,    35,262 ];

New:

NoConcatenate

LOAD *,

if((RowNo()=1 or POLICY_NO<>Previous(POLICY_NO)) ,YEAR,

if(POLICY_NO=Previous(POLICY_NO) , Peek('YEAR1'))) as YEAR1

Resident Data

Order by POLICY_NO,YEAR asc;

DROP Table Data;



Create Pivot Table

Dimensions:

YEAR1,

NEW_REN,

YEAR


Expression:

Count(POLICY_NO)


upaliwije
Creator II
Creator II
Author

Thanks Kush

One more help from You. same If I want to tabulate policies relating to a particular but were not renewed in subsequent years how can I script it please

Kushal_Chawda

If there is One New policy created in 2013 and which is not renewed in 2014, you need to list our this policy. this is what you mean?

upaliwije
Creator II
Creator II
Author

I want to show number of policies that were not renewed in the same table as follows

     

YEARNEW_RENYEAR20122013 2014 2015
RRNRRNRRNR
2012NEW 2
2012REN 24 2 1
2013NEW 1
2013REN 1
2014NEW 2
2014REN 2
Total 45 5 3
Kushal_Chawda

Output is not clear to me. Can you send the output in excel?

upaliwije
Creator II
Creator II
Author

It is like this

There were 4 policies in 2012 (new 2+ ren2)

in 2013 all 4 policies were renewed therefore not renewed policies is 0

In 2014 out 4 policies in 2012 only 2 were renewed balance 2 fall into not renewed catagory

In 2015 1 is renewed and 3 not renewed

Hope u understand my need

below is the sample

    

YEARNEW_REN20122013 2014 2015
RenewedRenewedNot RenewedRenewedNot RenewedRenewedNot Renewed
2012NEW2
2012REN2402213
2013NEW 1
2013REN 10 1
2014NEW 2
2014REN 2
Total 45 5 3

Pls help

upaliwije
Creator II
Creator II
Author

Hi Kush

Hope my illustration will help you find an answer my issue. Will you please help me with a sloution