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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Check itens included in other table

I have two tables called BILL and PAYMENT.

How can i create in BILL table a column to indicate only the bills that has a payment in PAYMENT table associated?

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Same with mapping table. Usually much faster...


PAYMENT:

LOAD BillID, ..... // Load everything you need

FROM DataSource (options);

MapHasPayment:

MAPPING LOAD DISTINCT BillID, 'Y' AS F2 RESIDENT PAYMENT;

BILL:

LOAD BillID,

     applymap('MapHasPayment', BillID, 'N') AS HasPaymentFlag,

     .... // Load everything you need

FROM OtherDataSource (options);

No need to drop Mapping Table. Disappears automatically at the end of the script run

View solution in original post

2 Replies
petter
Partner - Champion III
Partner - Champion III

In your load script you could do this:

PAYMENT:

LOAD

     BillNo,

     .....

FROM      // or ;SQL SELECT ...

     .....;

HAS_PAYMENTS:

LOAD DISTINCT

     PaymentBillNo

RESIDENT

     PAYMENT;

BILL:

LOAD

     BillNo,

     If( Exists('PaymentBillNo') , 'Y' , 'N') AS HasPayments,

     ....

FROM        // or ;SQL SELECT ....

     .....;

DROP TABLE HAS_PAYMENTS;

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Same with mapping table. Usually much faster...


PAYMENT:

LOAD BillID, ..... // Load everything you need

FROM DataSource (options);

MapHasPayment:

MAPPING LOAD DISTINCT BillID, 'Y' AS F2 RESIDENT PAYMENT;

BILL:

LOAD BillID,

     applymap('MapHasPayment', BillID, 'N') AS HasPaymentFlag,

     .... // Load everything you need

FROM OtherDataSource (options);

No need to drop Mapping Table. Disappears automatically at the end of the script run