Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
aetingu12
Creator
Creator

Overriding existing Column with new imported table

All,

I have a Loader Script as such:

Table_1:

Load ID, CUSTOMER_NAME, REGION

FROM [\\test\data.qvd]

(qvd);

Table_2:

Load ID, PRODUCT

FROM [\\test\data2.qvd]

(qvd);

Which creates the FIELDS ID,CUSTOMER_NAME, REGION and PRODUCT for each ID (So joins the tables)

then I import an excel spreadsheet as:

Excel_1:

Load ID, REGION

FROM [\\test\excel.xlsx]

(ooxml, embedded labels, table is Sheet1)

Excel_1 table has updated REGION codes for select IDs.  So I want to be able to do something like this in SQL but in Qlikview:

Case when Excel_1.ID = Table_1.ID then Excel_1.REGION else Table_1.REGION end as REGION.

Is this possible?

Regards,

Aksel

1 Solution

Accepted Solutions
neelamsaroha157
Specialist II
Specialist II

Table_1:

load * inline [

ID,CUSTOMER_NAME, REGION

2018,A, x

2019,B, y

];

Left Join

Excel_1:

load * inline [

ID, new_REGION

2018,z

];

LOAD *, if(IsNull(new_REGION), REGION, new_REGION) as Final_Region

Resident Table_1;

DROP Table Table_1;

Here is the output:

Capture2.PNG

You can drop the REGION and new_REGION field.

View solution in original post

5 Replies
neelamsaroha157
Specialist II
Specialist II

There are multiple ways of doing this, here is one of them-

Left join Excel_1 to Table_1 on ID, rename field REGION to something like New_REGION and then resident the final output table.

Add another field as if(IsNull(new_REGION), REGION, new_REGION) as Final_Region.


neelamsaroha157
Specialist II
Specialist II

Check this out

aetingu12
Creator
Creator
Author

Apologies, I am on corporate computer which doesn't allow downloading files.

Would it be possible to paste the code?

neelamsaroha157
Specialist II
Specialist II

Table_1:

load * inline [

ID,CUSTOMER_NAME, REGION

2018,A, x

2019,B, y

];

Left Join

Excel_1:

load * inline [

ID, new_REGION

2018,z

];

LOAD *, if(IsNull(new_REGION), REGION, new_REGION) as Final_Region

Resident Table_1;

DROP Table Table_1;

Here is the output:

Capture2.PNG

You can drop the REGION and new_REGION field.

aetingu12
Creator
Creator
Author

Much appreciated!

Thanks for your patience and help.