Remove DataTable Duplicate based on one column, keep the last occurrence

Hi Folks, how is going?

I have a Datatable:

[OE-FCO,“5 678,2”,“5 679,7”,“5 679,8”,4633,“5 447,7”,4428,“5 361,2”,4347
OE-FCB,“8 407,8”,“8 409,2”,“8 409,2”,6825,“6 168,0”,5197,“6 218,3”,5249
OE-FZC,“7 189,0”,“7 189,9”,“7 189,9”,5804,“7 189,9”,5804,“7 189,9”,5804
OE-FFB,“9 012,1”,“9 013,1”,“9 013,1”,7224,“6 506,7”,5208,“6 429,1”,5245
OE-FZB,“7 465,0”,“7 466,1”,“7 466,1”,6078,“5 301,7”,4553,“6 486,6”,5203
OE-FZC,“7 189,9”,“7 192,0”,“7 192,0”,5805,“7 192,0”,5805,“7 192,0”,5805]

I want to have a DataTable Output which contains the non duplicate rows of Input, based on the first column, but to keep the last occurrence of the row.

Can you advise?

I tried to use:
Output = Input.AsEnumerable.Reverse.CopyToDataTable
to reverse the datatable first, but the first row stays still on top.

Thank You Guys

Hi @Hurmet_Noka

I think you re using read range with add headers properties checked.

As It will consider first row as header.

Try with uncheck the add headers properties!


1 Like

Okay great, this solves half of the problem. Now how to remove duplicate rows? Should i use BalaReva Package?


You can remove duplicate through this way


Hope it will work

hi @Hurmet_Noka

As @ghazanfar suggested you can try with the above method
By adding columns which you want to remove duplicates!




I want to remove duplicates based on one column but to Keep all other columns.

Thank You

Hi @Hurmet_Noka

Check with the Below thread and Use Distinct function instead of first!


1 Like

Hi @Hurmet_Noka

You can try this way
Adding the sample xaml file and excel file as well

Main.xaml (13.0 KB)
SAMPLE.xlsx (9.0 KB)

There is another method as well where u had to python code and executed it via uipath,

Nived N

Perfect. Thank You

Do you have the other method with the python code…i like python but never tried to use it wit UiPath

Hi @Hurmet_Noka
Sure, there is python code which u can do this as well using pandas library,

code is

import pandas as pd

df= pd.read_excel('SAMPLE.xlsx')



This is the python code u can try. To execute it via UiPath, u can use Python activity in uipath for this

This is an optional but u can explore if needed :blush::blush::blush::blush:

Nived N

1 Like

Amazing, Thanks

1 Like

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