Get all against unique value in row

Hi,

I want to k
image
now how to get all values against a unique values in excel.

If you see screenshot, there are name and car column.
So I want to get all cars against a unique name. eg. Like Andrew having which cars .
I am attaching the excel.
test.xlsx (9.7 KB)

Hi @sshitol

Welcome to UiPath community

How about this expression

(From d In DtBuild.AsEnumerable
Group d By k=d("Name").toString.Trim Into grp = Group
Let nj = String.Join(",",grp.Select(Function (n) n("Car").toString.Trim))
Let ra = New Object(){k,nj}
Select r = DtOutput.Rows.Add(ra)).CopyToDataTable

Regards
Gokul

HI @sshitol

Check out the XAML file

LinqGroupby.xaml (11.0 KB)

image

Output

image

Regards
Gokul

1 Like

Hi @Gokul001 ,
Its proper, but rather than getting output in combine, can we get output in row by row.

eg. Andrew,“BMW,Tesla,Hyundai” its in 1st time

John,“Merce,Volks” 2nd time

Elon,“Honda,Maruti” 3rd time

may be split output row by row

Can you share the expected Output @sshitol

I want output not in combine format.
It should be row by row.
Now output is coming like below.
Andrew,“BMW,Tesla,Hyundai”
John,“Merce,Volks”
Elon,“Honda,Maruti”

But I want it separate like
Andrew,“BMW,Tesla,Hyundai”

once it done then
John,“Merce,Volks”

after this
Elon,“Honda,Maruti”

like how we print in for each row

In general the case looks like a groupBy Scenario / Filter case

A strategy would be adapted depending on what you want to to with. One of many options is to group the rows by name and then package it
e.g. List(Of List(of Datarow)) - outer List: Groups, inner List: the corresponding group members

Assign Activity:
Groups | DataType: List(Of List(of Datarow)) =

(From d In YourDataTableVar.AsEnumerable
Group d By k=d("Name").toString.Trim Into grp = Group
Select g = grp.ToList).toList

A variation of this is to return a list of datatables | 1 DataTable = 1 Group and its members

Assign Activity:
TableList| DataType: List(Of DataTable) =

(From d In YourDataTableVar.AsEnumerable
Group d By k=d("Name").toString.Trim Into grp = Group
Select t = grp.CopyToDataTable).toList

Hi @Gokul001 ,

any option to do this

Hello @sshitol
Refer to this Xaml file you may get some idea
Forum_NameGrouping.zip (151.3 KB)

image

Hi @sshitol

Check out the XAML file

LinqGroupby.xaml (14.5 KB)

Regards
Gokul

Hi @Gokul_Jayakumar ,

I am unable to see any write line or log message activity in your xaml file, then how its writing output

thanks @Gokul001

1 Like

@sshitol
You Can see the Log message at end of For each loop


I am able to see only 3 activities in my studio

@sshitol
It’s maybe a version issue

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.