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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
masalas232
Contributor
Contributor

Rows to Column

I have data in the following format: 

TransID ProductID
1 a
1 b
1 c
2 b
2 d
2 e
2 f

 

Need to transform into the following:

TransID Products
1 a, b, c
2 b, d, e, f
Labels (1)
3 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Use Concat() and Group By:

LOAD
  TransID,
  Concat(ProductID, ', ') as Products
Inline [

TransID ProductID
1 a
1 b
1 c
2 b
2 d
2 e
2 f
] (delimiter is '\t')
Group by TransID
;

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

Hania
Creator
Creator

you can use Generic load .

https://community.qlik.com/t5/Design/The-Generic-Load/ba-p/1473470

 

hope this is useful!

Chanty4u
MVP
MVP

// load the original table

LOAD

    TransID,

    ProductID

FROM data.csv (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

 

// group by TransID and concatenate ProductIDs

LOAD

    TransID,

    concat(ProductID, ', ') AS Products

RESIDENT

    OriginalTable

GROUP BY

    TransID;

 

// drop the original table

DROP TABLE OriginalTable;