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: 
Not applicable

New column in load script

Hi All,

I have a main table, and then want to derive a new field based on a column. The main table comes from different spreadsheets and the result is something as below

  

stepDataColumn
A-1data1
B-2data2
B-3data1
B-4data3
C-5data4
A-1data4
B-2data4
B-3data3
B-4data1
C-5data1
A-1data2

Now I want to add another column after, based on DataColumn, if DataColumn is data1 or data2, then new column should be Data1or2, DataColumn is data3 or data4 then new column should be Data3or4. I should use a preceding load and create a Temp Table and then join it to my main table - should be so easy but can;t get it to work.


stepDataColumnNew Column
A-1data1Data1or2
B-2data2Data1or2
B-3data1Data1or2
B-4data3Data3or4
C-5data4Data3or4
A-1data4Data3or4
B-2data4Data3or4
B-3data3Data3or4
B-4data1Data1or2
C-5data1Data1or2
A-1data2Data1or2


Thanks!

1 Solution

Accepted Solutions
sunny_talwar

This did not work:

LOAD step,

          DataColumn,

         If(Match(DataColumn, 'data1', 'data2'), 'Data1or2', 'Data3or4') as [New Column]

FROM ....

View solution in original post

15 Replies
sunny_talwar

This did not work:

LOAD step,

          DataColumn,

         If(Match(DataColumn, 'data1', 'data2'), 'Data1or2', 'Data3or4') as [New Column]

FROM ....

krishnacbe
Partner - Specialist III
Partner - Specialist III

Hi,

Hope the attached qvw helps.

Regards

Krishnapriya

Not applicable
Author

Thanks! This works

trdandamudi
Master II
Master II

May be as attached:

Data:

Load 

Step,

DataColumn,

If(DataColumn='data1' OR DataColumn='data2','Data1or2','Data3or4') as NewColumn

Inline [

Step, DataColumn,

A-1, data1

B-2, data2

B-3, data1

B-4, data3

C-5, data4

A-1, data4

B-2, data4

B-3, data3

B-4, data1

C-5, data1

A-1, data2

];

Not applicable
Author

Now it gives me synthetic keys, is it OK?

sunny_talwar

It should not give you synthetic keys. Are you creating this in a resident load? I would suggest you to create it in the first load when you are loading it from your database

Not applicable
Author

Yes I have to use Resident because my main table is coming from different sources...Can you advise please on how I can use resident load and not get synthetic keys? or maybe use a preceding load?

krishnacbe
Partner - Specialist III
Partner - Specialist III

Hi,

Please check the sample I have attached. It doesn't have synthetic key.

sunny_talwar

Would you be able to share the script you are using? We might be able to suggest you the best alternative once we see what exactly do you have