Hi Friends,
I want to write duplicate if same name appears 2 times in excel data.
I am using Reframework so please share linq query if possible.
See below screenshot.
Hi Friends,
I want to write duplicate if same name appears 2 times in excel data.
I am using Reframework so please share linq query if possible.
See below screenshot.
Try this:
dtInput.AsEnumerable().ToList().ForEach(Sub(row) row(“Status”) = If(dtInput.AsEnumerable().Count(Function(r) r(“Names”).ToString.Trim = row(“Names”).ToString.Trim) > 1, “Duplicate”, “”))
Regards.
Hi @tolga.kamci
See below error occured, can you pls suggest.
Try this here dt_data is the main Data Table and dt_result is the resultant Data Table
dt_result = dt_data.AsEnumerable().Select(Function(x) If(dt_data.AsEnumerable().Count(Function(y) y("Name").ToString() = x("Name").ToString() AndAlso _
y("Date").ToString() = x("Date").ToString()) > 1, _
dt_data.Clone.Rows.Add({x("Name"), x("Date"), "Duplicate"}), _
dt_data.Clone.Rows.Add({x("Name"), x("Date"), ""}))).CopyToDataTable()
It works for my test cases!
Hope this helps!
I would suggest you implement solution within Excel only. You can apply below formula under Status column
=IF(COUNTIF($A$2:$A$100, A2) > 1, “Duplicate”, “”)
Please modify the range based on your requirement. Better to find the last row dynamically instead of hard coding
Also there are options to apply formula using UiPath in runtime and populate the details
Let me know if this helps you @Jeeru_venkat_Rao
Thank you friends for your quick responses and I will try other approaches as well.
It tried below code and its working fine to me
Duplicate variable type–>dictionary(string,int32)
Duplicate=(From row In dt_Duplicatefinder.AsEnumerable()
Group row By Key = row(“Name”) Into grp = Group
Where grp.Count() > 1
Select grp).ToList()
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.