Issue when grouping decisions number then once finished the loop it doesnt continue to the next decisionsnumber

I have an issue I m using grouping decisions number then once finished the loop it doesnt continue to the next decisionsnumber.

Example of the flow:

Assign Groups = dt_check.AsEnumerable().
GroupBy(Function(r) r(“7-N° Décision”).ToString.Trim).Distinct().
ToList()

variable type => List IGrouping System String, system Datatable

Then For each grp in Groups

Inside the for ecah grp in groups I’ve put a
For each rowdecision in grp (Argument type System.Data.DataRow)

And it works It input the correct number of rows for a unique 7-N° Décision.
However when it finish the loop then he must continue to the next rows that have another 7-N° Décision in it but its not the case. Instead he tried to proceed the next row.

Example of info in my Excel file

I want that he proceed all the first 2 rows together then once finished the loop he must start again to the next uniqueNDecision which is row 3 (then proceding all the 4 rows together) then he must continue to the row 7

Just a precision after my loop is finished it always start again to the first row it doesnt continue to the next grp weird . Your precious help would be much appreciated. I think I’m almost there but need help thx.

Hi Maic

I would to it like this, almost the same as for you :slight_smile: In the list of unique “group, I would use ‘Select’ instead of GroupBy.

dt_Check.AsEnumerable.Select(Function(r) r(“7-N° Décision”).ToString.Trim).Distinct.ToList()

Now I got a list of string with all the unique “groups”, then I would loop that list of groups. And for each group I would take a subset of the original datatable and loop through that, This way I find it easier to debug and see what is has found as result.

Assign activity with a datatable variable and this as the value (“currentGroup” is the list item):

dt_Check.AsEnumerable.Where(Function(x) x(“7-N° Décision”).ToString.Trim.Equals(currentGroup)).CopyToDataTable

My test data:

My result:

I hope this helps

not really. I tried but I still have the same result.

It always group the rows correctly but always continue at row 1

However i want that bot continue at row 3 as the N7Decision is different

Any other idea is more than welcome thanks in advance all

Also note that at the beginning of my bot I have a for each row in dt_check set up

and then I add a if condition => Row.item(“21-A Factuer O/N”).ToString>“0” andAlso (String.IsNullOrWhiteSpace(Row(“14-Interruption Mandat”).ToString) OrElse CDate(Row.Item(“14-Interruption Mandat”).ToString) > New DateTime(Now.Year, Now.Month, 1).AddMonths(-1).AddDays(-1))

Then I use for each grp in groups (System.Linq.IGrouping<System.String.SystemData.Dat Row)

Then I use for each rowDecision in grp (system.Data.DataRow)

Hope this can help me found why it always restart at row 1 starting for each grp in groups

Hi Maic

I’m not sure I follow.

You loop through all rows in the shown spreadsheet (dt_Check) and then start with the if:

Row.item(“21-A Factuer O/N”).ToString>“0” andAlso (String.IsNullOrWhiteSpace(Row(“14-Interruption Mandat”).ToString) OrElse CDate(Row.Item(“14-Interruption Mandat”).ToString) > New DateTime(Now.Year, Now.Month, 1).AddMonths(-1).AddDays(-1))

If that is true, then you loop through the groups?

Will a group contain all the rows from dt_check with the the same group in the column ‘7-N° Décision’?

What should the output be? or could you show an example of how you would like the flow to be?

Hi, I was able to solve my problem by removing first for each row in dt_check at the beginning of my. Now it always continue to th next group.