I want to calculate number of data associated with one record

In above screenshot. Highlighted Workorder are duplicate but they have different DWR. Now my requirement is system will delete the duplicate WO but before that they put the count of DWR which are associated with that work order in Count DWR column.

I have this data in data table.

@Puneet_Singh1

Please use this in assign

dtoutput = dt.Clone()

dtoutput = (From d In DT.AsEnumerable
Group d By k=d("Work Order").toString.Trim Into grp = Group
Let c = grp.Count.ToString
Let ra = New Object(){grp.First()(0),grp.First()(1),k,c}
Select r = DtOutput.Rows.Add(ra)).CopyToDataTable

cheers

Thanks. Here dtoutput is the datatable which is already extrated right. I already stored the data in one table

@Puneet_Singh1

Yes dtoutput is where transformed data is stored which has 4 columns

Cheers

Sorry anil i am little confused.
OPEN DWRS - EV INTERNAL.xlsx (58.2 KB)

In Attached excel i have data which i copied from data table. I used your query but getting an error.

Please let me know where i am wrong.

@Puneet_Singh1

  1. dt is the input table which is your extractdatatable
  2. dtoutput would be your output you need to create it

cheers

Thanks Anil,

Its not writing the value in D.

Code

Hi Anil its working but my other data removed from excel. I want a complete data with DWR Count. See excel file i want all data which is in local file along with DWR count.
OPEN DWRS - EV INTERNAL.xlsx (17.8 KB)
OPEN DWRS - EV INTERNAL-Local.xlsx (65.6 KB)

@Puneet_Singh1

You need to write the data back you are only reading the data…finaldt is where data is present

cheers

Can we apply this logic directly to attached excel file. I am doing but its now working.
OPEN DWRS - EV INTERNAL-Local.xlsx (66.1 KB)

Please help.