Filter dataset into two variables filtered by count

I have an activity that reads a file to variable we’ve called output_DVPName
The table looks something like this
[LocationGroup][Name][Other info][More info]
[12345][Dr Suess][Other info][More info]
[12345][Mr Magoo][Other info][More info]
[45678][ ][Other info][More info]

We need to group these into two variables, count greater that 1 and count less than 2
This should looks something like this

Table_Less_Than_2
[45678][ ][Other info][More info]

Table_Greater_Than_1
[12345][Dr Suess][Other info][More info]
[12345][Mr Magoo][Other info][More info]

Our selector expression looks like this
(From p In DVPName.AsEnumerable()
Group By
col1=p(“LEVEL 2”).ToString
Into Group
Select out_put_DVP_List.Rows.Add({col1,Group.count()})).CopyToDatatable

I am trying to write the pseudo code equivilent of
Select [LocationGroup][Name] from Data where Count(LocationGroup) > 1 as GreaterThan1
Which would yeild
[12345][Dr Suess][Other info][More info]
[12345][Mr Magoo][Other info][More info]

and then
Select [LocationGroup][Name] from Data where Count(LocationGroup) < 2 as LessThan2
which would yeild
[45678][ ][Other info][More info]

@nyra.y.ruiz
Welcome to the forum

give a try on:
out_put_DVP_List is an empty prepared datatable witch 2 cols: LocationGroup, count

Table less 2:

(From d In DVPName.AsEnumerable()
Group By k=d(“LocationGroup”).ToString.Trim Into grp=Group
Where grp.Count < 2
Let ra = new Object(){k, grp.Count()}
Select r= out_put_DVP_List.Rows.Add(ra)).CopyToDatatable

Table greater 1:

(From d In DVPName.AsEnumerable()
Group By k=d(“LocationGroup”).ToString.Trim Into grp=Group
Where grp.Count > 1
Let ra = new Object(){k, grp.Count()}
Select r= out_put_DVP_List.Rows.Add(ra)).CopyToDatatable

feel free to modify like:

(From d In DVPName.AsEnumerable()
Group By k=d(“LocationGroup”).ToString.Trim Into grp=Group
Where grp.Count > 1
From g in grp
Select r= g).CopyToDatatable

Thank you so much! Me and the other developer will not be able to work on this until later today or Monday - So I will work with them and tinker with this solution and get back to you here.

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