i have a excel file, with multiple columns i want to write unique rows in sheet2
Sample input:

Expected ![]()

i have a excel file, with multiple columns i want to write unique rows in sheet2
Sample input:

Expected ![]()

dt1.AsEnumerable().GroupBy(Function(row) row("CityId")).Select(Function(group) group.First()).CopyToDataTable()
uniqueRows = (From row In dtInput.AsEnumerable()
Select row).Distinct(DataRowComparer.Default).CopyToDataTable()
In assign activity Try this linq query
Hii @gantamohan502
Try this query:
(
From row In DT_input
Group row By a = row("CityId").ToString.Trim Into grp = Group
Select grp.First
).CopyToDataTable
Cheers
Try this
DT = DT.AsEnumerable().
GroupBy(Function(row) row("CityId").ToString).
Select(Function(g) g.First()).CopyToDataTable()
Input:

Output:

Regards,
You can achieve it by using the LINQ Expressions,
→ Use Read Range workbook activity to read the excel and store in a datatable called Input_dt.
→ Then insert the assign activity and give the below LINQ Expression,
- Assign -> Output_dt = Input_dt.AsEnumerable.GroupBy(Function(X) New With { Key .Column1 = X("CityId"), Key .Column2 = X("CityName") }).Select(Function(Y) Y.First).CopyToDataTable()
→ Then use the write range workbook activity to write the Output_dt to the excel.
By using LINQ Expressions also we can remove the duplicte rows in the excel.
Hope it helps!!
dt1.AsEnumerable().GroupBy(Function(row) row("CityId")).Select(Function(group) group.First()).CopyToDataTable()

Input

Output

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