Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Group text from multiple rows into a single column, comma separated

Hi Qlik-ers,

I was wondering if something like this is possible :

Sample table that I have :

NameCompanyProduct CodeValue
SeanCompany ADCA120
FTY240
TUG470
SLU510
JamesCompany BPSR280

YTI5

100
POL410

What I would like to achieve :

NameCompanyProduct CodeValue
SeanCompany ADCA1, FTY2, TUG4, SLU5140
JamesCompany BPSR2, YTI5, POL4190

I would like to concatenate the Product into a single row separated by a comma for each Name and Company.

Appreciate your help.! thanks.

Shan.

Labels (1)
1 Solution

Accepted Solutions
MarcoWedel
MVP
MVP

... or more dynamic on the front end side:

LOAD Name,

     Company,

     [Product Code],

     Value

FROM

[http://community.qlik.com/thread/115379]

(html, codepage is 1252, embedded labels, table is @1, filters(

Replace(1, top, StrCnd(null)),

Replace(2, top, StrCnd(null))

));

QlikCommunity_Thread_115379_Pic5.JPG.jpg

QlikCommunity_Thread_115379_Pic2.JPG.jpg

QlikCommunity_Thread_115379_Pic3.JPG.jpg

QlikCommunity_Thread_115379_Pic4.JPG.jpg

regards

Marco

View solution in original post

4 Replies
MarcoWedel
MVP
MVP

Hi Shan,

try

QlikCommunity_Thread_115379_Pic1.JPG.jpg

LOAD

  Name,

  Company,

  Concat([Product Code], ',') as [Product Code],

  Sum(Value) as Value

Group By Name, Company;

LOAD Name,

    Company,

    [Product Code],

    Value

FROM

[http://community.qlik.com/thread/115379]

(html, codepage is 1252, embedded labels, table is @1, filters(

Replace(1, top, StrCnd(null)),

Replace(2, top, StrCnd(null))

));

regards

Marco

MarcoWedel
MVP
MVP

... or more dynamic on the front end side:

LOAD Name,

     Company,

     [Product Code],

     Value

FROM

[http://community.qlik.com/thread/115379]

(html, codepage is 1252, embedded labels, table is @1, filters(

Replace(1, top, StrCnd(null)),

Replace(2, top, StrCnd(null))

));

QlikCommunity_Thread_115379_Pic5.JPG.jpg

QlikCommunity_Thread_115379_Pic2.JPG.jpg

QlikCommunity_Thread_115379_Pic3.JPG.jpg

QlikCommunity_Thread_115379_Pic4.JPG.jpg

regards

Marco

maxgro
MVP
MVP

source:

load

  if(len(trim(Name))=0, peek(Name), Name) as Name,

  if(len(trim(Company))=0, peek(Company), Company) as Company,

    [Product Code],

    Value;   

load

  Name,

    Company,

    [Product Code],

    Value

FROM

[http://community.qlik.com/thread/115379]

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

table:

NoConcatenate load

  Name, Company,

  concat([Product Code], ', ') as [Product Code],

  sum(Value) as Value

Resident source

group by Name, Company;

DROP Table source;

Not applicable
Author

Thanks guys. Got it. Using concat as an expression works!