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!

15 Replies
Not applicable
Author

Not able to share the whole script

but this is basically what I'm doing

MainTable:

Crosstable(A,B)

Load....From

Crosstable(A,B)

Load...From

Crosstable(A,B)

Load...From

(for different data sources)

Then I have my MainTable built, basically same as I showed you.

Then I've added the following, which gives me synthetic key

LOAD step,

          DataColumn,

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

RESIDENT MainTable;

sunny_talwar

Give this a shot:

MainTable:

Crosstable(A,B)

Load....From

Crosstable(A,B)

Load...From

Crosstable(A,B)

Load...From

(for different data sources)

FINALMainTable:

LOAD *,

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

RESIDENT MainTable;


DROP Table MainTable;

Not applicable
Author

Great! Synthetic keys are gone

sunny_talwar

Awesome

Not applicable
Author

thanks!!

Not applicable
Author

thanks!!