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: 
mattphillip
Creator II
Creator II

Merging two fields together

Hi, I'm hoping someone can help. I have a large dataset, and it includes two columns with similar values (academic  subjects - they cover different years with the second being a slightly revised list). I'm looking for a way to combine these two field ('Subjects 13/14' and 'Subjects 14/15') into a single 'Subject' field whilst keeping their respective values.

Is there any way to do this?

Appreciated.

Matt

33 Replies
mattphillip
Creator II
Creator II
Author

Sorry had // them out as I thought it was initially causing the error. Just tried putting it back in and got exactly the same error.

SET ThousandSep=',';

SET DecimalSep='.';

SET MoneyThousandSep=',';

SET MoneyDecimalSep='.';

SET MoneyFormat='£#,##0.00;-£#,##0.00';

SET TimeFormat='hh:mm:ss';

SET DateFormat='DD/MM/YYYY';

SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

LOAD UniqueKey,

     Year,

     Unis,

     [JACS-A],

     [JACS-B]

FROM

(ooxml, embedded labels, table is Sheet1);

Table:

Noconcatenate

Load UniqueKey,

Year,

University,

[JACS-A] as JACS

Resident Table;

concatenate

Load

UniqueKey,

Year,

University,

[JACS-B] as JACS

Resident Table;

FROM

(ooxml, embedded labels, table is Sheet1);

Anonymous
Not applicable

You have not named Intial table.

Try:

TableA:

Load

UniqueKey,

Year,

University,

[JACS-A],

[JACS-B]

FROM

(ooxml, embedded labels, table is Sheet1);

Table:

Noconcatenate

Load UniqueKey,

Year,

University,

[JACS-A] as JACS

Resident TableA;

concatenate

Load

UniqueKey,

Year,

University,

[JACS-B] as JACS

Resident TableA;

mattphillip
Creator II
Creator II
Author

Good news, no errors. However, please see below. Is there anyway to do this and no create the blank entries?

table.jpg

sunny_talwar

Try this:

Table:

CrossTable (Subject, Data, 3)

LOAD UniqueKey,

          Year,

          University,

          Subject 12012/13,

          Subject 12013/14

FROM sourceFile;


FinalTable:

NoConcatenate

LOAD *

Resident Table

Where Len(Trim(Data)) > 0;


DROP Table Table;

mattphillip
Creator II
Creator II
Author

Thanks for this Sunny. It's not quite what I had in mind though.

test-table.jpg

I was looking for the values to be combined into a single field like below:

UniqueKeyYearUniversityJACS
12012/13Uni1Computing
22012/13Uni2Medicine
32012/13Uni3Art
42012/13Uni4History
52013/14Uni1Food
62013/14Uni2Accounting
72013/14Uni3English
82013/14Uni4Geography

Any idea whether this can be done?

Thanks!

shambhub
Creator
Creator

Hi Matt,

Try like this you will get it.

Load UniqueKey,

     Year,

     University,

     [Subject 2012/13],

     [Subject 2013/14],

     If(IsNull([Subject 2012/13]),[Subject 2013/14],[Subject 2012/13]) as Subject;

LOAD UniqueKey,

     Year,

     University,

     [Subject 2012/13],

     [Subject 2013/14]

FROM

(ooxml, embedded labels, table is Sheet1);

Best Regards

Shambhu B

sunny_talwar

This is what I gave you:

Capture.PNG

Script:

Table:

CrossTable (Subject, Data, 3)

LOAD UniqueKey,

    Year,

    University,

    [Subject 2012/13],

    [Subject 2013/14]

FROM

[https://community.qlik.com/thread/186661]

(html, codepage is 1252, embedded labels, table is @1);

FinalTable:

NoConcatenate

LOAD *

Resident Table

Where Len(Trim(Data)) > 0;

DROP Table Table;

mattphillip
Creator II
Creator II
Author

My apologies Sunny, didn't realise I hadn't added the new 'Data' field to my table.

Many thanks.

mattphillip
Creator II
Creator II
Author

Hi Sunny, just one final question - in the line 'CrossTable (JACS,Data,3)' what does the 3 refer to?

sunny_talwar

3 means that start the CrossTable starting with field 4 and keep the first 3 fields as columns.