Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Load script based on condition in Qlik sense

I have to load data based on condition like

CUSTOMER     POLICY_NO

A                       P1

A                       P2

B                       P1

C                       P2

D                       P1

D                       P2

If the customer is enrolled to  both P1 and P2 policies, then load only P2.

Output:

CUSTOMER     POLICY_NO

A                       P2

B                       P1

C                       P2

D                       P2

5 Replies

Re: Load script based on condition in Qlik sense

Few questions.

1. Every Customer has only two policies or it will be more policies Ex (P1,P2,P3....)

2. Will it be only two policies P1,P2.

luke1986
New Contributor III

Re: Load script based on condition in Qlik sense

Try This:

data:

LOAD * INLINE [

    CUSTOMER, POLICY_NO

    A, P1

    A, P2

    B, P1

    C, P2

    D, P1

    D, P2

];

test:

Noconcatenate LOAD

CUSTOMER,

'P'&Max(right(POLICY_NO,1)) as POLICY_NO

Resident data

Group By CUSTOMER;

Drop Table data;

vinieme12
Esteemed Contributor II

Re: Load script based on condition in Qlik sense

I think the main component here would be DATES!

I assume your exact requirement would be to load latest Policy taken?

If not please confirm your exact requirement

MVP
MVP

Re: Load script based on condition in Qlik sense

Hi,

Check below script

Data:

LOAD * INLINE [

    CUSTOMER, POLICY_NO

    A, P1

    A, P2

    B, P1

    C, P2

    D, P1

    D, P2

];

INNER JOIN(Data)

LOAD

     CUSTOMER,

     Maxstring(POLICY_NO) AS POLICY_NO

RESIDENT Data

GROUP BY CUSTOMER;


Regards,

Jagan.

Re: Load script based on condition in Qlik sense

If you have more than policy per customer and may be two simple do this in UI part for the customer

Ex:-

LOAD * INLINE [

    CUSTOMER, POLICY_NO

    A, P1

    A, P2

    B, P1

    C, P2

    D, P1

    D, P2

];

Straight Table:-

Dim:- CUSTOMER

Expression:- =MaxString(POLICY_NO)

OP3.PNG