How to delete row for the same total amount

Dear Experts,

As below image, I would like to remove duplicate doctotal amount and remain one line only per docno.
I could achieve by using for each row and delete duplicate lines. But for data row more than a million records, it is taking time and indexing problem might occur. So is there any other background coding to achieve this with faster without using for each row activity. Thanks.

image

Hi @Htwe_Ko_Ko_Wynn ,

Hope this may help you,To select distinct/unique values in a column use the below condition in assign activity

OutputDT = DataTable.DefaultView.ToTable(true,“ColumnName”)

1 Like

Hi Nithyac,

By the way how can I mark these duplicate data to 0 and leave the bottom one with amount as follows: Let me know if I can use without using for each row activity. Thanks again.

image

Hi,

Sorry for late reply, I couldn’t able to find solution to your scenario using query,
I would request @Yoichi @ppr to give solution or any suggestions to the above said scenario.
Thanks in advance.

Hi,

No problem, I used a macro as write cell in excel and auto fill range.

Hi @Htwe_Ko_Ko_Wynn ,

Hope the following sample helps you.

img20211215-3

dt = dt.AsEnumerable.GroupBy(Function(r) r("DocNo")).SelectMany(Function(g) g.Select(Function(r,i) dt.Clone.LoadDataRow({r("DocNo"),r("ItemDesc"),if(i=g.Count-1,CInt(r("TotalAmount").ToString),0)},False))).CopyToDataTable

Sample20211215-1.zip (2.7 KB)

Regards,

1 Like

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