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

Creating new column from already existing columns

I have 3 columns as Below

A   B    C

1    2    4

2    1    3

3    5    1

I want to create 2 columns from the above 3 columns like below.

NewColumn   Value

A                     6

B                     8

C                     8

How can I acheive this ?

4 Replies
sunny_talwar

May be like this:

Table:

LOAD * Inline [

A,  B,    C

1,    2,    4

2,    1,    3

3,    5,    1

];

FinalTable:

LOAD Sum(A) as Value,

  'A' as NewColumn

Resident Table;

Concatenate(FinalTable)

LOAD Sum(B) as Value,

  'B' as NewColumn

Resident Table;

Concatenate(FinalTable)

LOAD Sum(C) as Value,

  'C' as NewColumn

Resident Table;

DROP Table Table;

settu_periasamy
Master III
Master III

One more solution may be

T1:

LOAD '' as dummy,*;

LOAD * INLINE [

    A, B, C

    1, 2, 4

    2, 1, 3

    3, 5, 1

];

T2:

CrossTable(Field, Data)

LOAD dummy,

     A,

     B,

     C

Resident T1;

DROP Table T1;

DROP Field dummy;

NoConcatenate

Final:

LOAD Field,sum(Data) as Data Resident T2 Group by Field;

DROP Table T2;

sunny_talwar

I like this more than my solution. Thanks for sharing this Settu

settu_periasamy
Master III
Master III

Thanks sunindia