Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
JustinDallas
Specialist III

Concat/Group All Field Values by Value

Hello Folks,

 

I'm working with the following problem, below is the table that I'm starting with.

 

DummyTable:
Load * Inline
[
	PersonId, Course
	1       , Physics
	1		, Chemistry
	2		, Fingerpainting	
	2		, Transmission Maintenance
	2		, Alchemy
	3		, Magic Tricks
	3		, Traffic Guarding 101
	
]
;

 

I'm trying to get a table that looks like this, where I CONCAT all the Courses based on their PersonId:

PersonId CourseList
1 Physics, Chemistry
2 Fingerpainting, Transmission Maintenance, Alchemy
3 Magic Tricks, Traffic Guarding 101

 

I'm completely unsure about how to go about this, even though I swear I've done it in the past.

 

Any help is greatly appreciated.

Labels (3)
1 Solution

Accepted Solutions
BrunPierre
Partner - Master

Like this

NoConcatenate
load PersonId,
concat(distinct Course,', ') as Course
Resident DummyTable

group by PersonId;

drop table DummyTable;

exit script;

peter_brown_2-1661462267886.png

 

 

 

 

 

View solution in original post

3 Replies
Digvijay_Singh

Here you go - 

DummyTable:
Load * Inline
[
PersonId, Course
1 , Physics
1 , Chemistry
2 , Fingerpainting
2 , Transmission Maintenance
2 , Alchemy
3 , Magic Tricks
3 , Traffic Guarding 101

]
;

Noconcatenate
Final:
Load PersonId, Concat(Course,',') as CourseList
resident DummyTable
Group By PersonId
;

Drop table DummyTable;

Digvijay_Singh

May be directly in the visual - 

Digvijay_Singh_0-1661461904119.png

 

BrunPierre
Partner - Master

Like this

NoConcatenate
load PersonId,
concat(distinct Course,', ') as Course
Resident DummyTable

group by PersonId;

drop table DummyTable;

exit script;

peter_brown_2-1661462267886.png