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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Merging tables

Question relating to granularity...  for optimal performance, here is my scenario:

I have table A, which includes PatientID, OrderID, and NurseID

I have table B, which is a detail of the Order, with OrderID and DrugID

Each OrderID in table A is 1 row of data.  An OrderID in table b can have 1 to multiple rows, depending on how many DrugID's were ordered.

How do i merge these tables so they are using the same granularity?

Example:

table A:

OrderID 201

table B:

OrderID 201  DrugID 1

OrderID 201  DrugID 2

OrderID 201  DrugID 3

Thanks for any input.

4 Replies
maxgro
MVP
MVP

- add PatientID and NurseID to TableB

- don't merge and stay with 2 tables

- concatenate

Not applicable
Author

how would I add them

maxgro
MVP
MVP

1.png

tableA:

load * inline [

OrderID, PatientID, NurseID

201, P1, N1

202, P2, N2

];

tableB:

load * inline [

OrderID, DrugID

201,  DrugID 1

201,  DrugID 2

201,  DrugID 3

];

join (tableB)

load *

resident tableA;

DROP Table tableA;

Not applicable
Author

Ok so I'm still new, but I asked a friend who's more experienced and he said that you should do a Left Join from Table 1 to Table 2

Left Join (Table1)

Load

     OrderID,

     DrugID;

From

[...\Datasources\Table2.qvd]

Edit: Just noticed someone else replied. Hope it worked!