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

Creating a comma separated list in a field from multiple records

This is something that I already have a solution for, but am thinking that there might be an easier or better way.

What I have is a table with a vendor number and a type. A vendor can be of one or more types. The users want to see the types in a comma separated fashion. See before and after example below.

error loading image

Here is how I am currently doing it:


Vendors:
LOAD * INLINE
[ Vendor, VendorType
123,A
123,B
124,A
125,A
125,C
126,B ];
ListTemp:
LOAD
'X' as VendorTypeList,
1 as Rec,
VendorType,
Vendor
RESIDENT Vendors;
ListTemp2:
LOAD
Vendor,
If (Previous(Vendor)=Vendor, Peek(VendorTypeList) & ' , ' & VendorType,VendorType) as VendorTypeList ,
numsum( Rec, peek('RecCount')) as RecCount
RESIDENT ListTemp
ORDER BY Vendor,VendorType;
DR0P TABLE ListTemp;
VendorList:
LOAD
Vendor,
MAXSTRING(VendorTypeList) as VendorTypeList
RESIDENT ListTemp2
GROUP BY Vendor
ORDER BY RecCount;

DR0P TABLE ListTemp2;


Any thoughts or ideas are greatly apreciated..

Frank

2 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

try this:


load
Vendor,
concat(VendorType, ' ,') as VendorTypes
resident
Vendors
group by
Vendor
;


sicilianif
Creator II
Creator II
Author

Thank you.. I knew I was making it much harder than it needed to be.