Hello Team,
I have data table with column name as “Participants” and I want to remove the duplicate rows from the same column from ascending order.
Hi,
If possible, can you share an example as file : input and expected output?
Regards,
Hi @Yoichi , sure
Consider below is the column " Participants"
Participants
1234
9987
5645
3678
5645
I want to remove duplicate rows from this column from ascending order ( I want to keep last value 5645 and remove the 3rd row value from ascending order)
Hey Soham,
Please try with below Query
dt_Data.AsEnumerable.
GroupBy(Function(row) row(“Invoice Item”).ToString()).
Select(Function(grp) grp.First()).
OrderBy(Function(row) row(“Invoice Item”).ToString()).
CopyToDataTable()
Step 1 - Group by the Column Values
Step 2 - Select 1st from each group
Step 3 - Order by the selected as ascending
Cheers😊
Hi,
Can you try the following sample?
dt.AsEnumerable.GroupBy(Function(r)r("Participants").ToString).Select(Function(g) g.Last()).OrderBy(Function(r) dt.Rows.IndexOf(r)).CopyToDataTable()
Sample20250130-4.zip (9.3 KB)
Regards,
As I’m using this query in assig activity inside the For each row in data table activity I’m getting error as " Collection was modified; Enumeration operation might not execute" please help
Sure, let me try this one as well
Thank you @Yoichi it worked for me but when we are coming out of for each activity again same “Collection was Modified; Enumeration operation might not execute” error is coming, please help
Yes tried, but still it’s coming up when we are coming out of for each row in data table activity
Hey @singh_sumit Thank you for replying, but it’s not working for keeping the last record of duplicate row
Hi,
Basically, It’s prohibited to modify original collection inside ForEach. Please review your logic.
Regards,
Thank you @Yoichi , it worked now
Thank you Everyone for your help and support .
It helped me to resolve my issue and it was new learning for me as well.