Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
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
its_anandrjs

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
Contributor III
Contributor III

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
Champion III
Champion III

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

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
jagan
Luminary Alumni
Luminary Alumni

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.

its_anandrjs

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