web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Removing duplicate row...
Power Automate
Answered

Removing duplicate rows from DataTable based on single Column

(0) ShareShare
ReportReport
Posted on by 5

Hello, I am looking for solution to remove duplicate rows in DataTable based on Column zero.
I cant use "add items " to list first and then delete.

 

Is there any script way to do it?

nabeelamjad_0-1703196646455.png

 

I have the same question (0)
  • UrosB Profile Picture
    11 on at

    Something similar to this (paste it into empty action window in PAD):

     

     

    Variables.CreateNewDatatable InputTable: { ^['ID', 'Name'], [1, $'''John'''], [2, $'''Anne'''], [1, $'''Paul'''] } DataTable=> FirstTable
    Variables.CreateNewDatatable InputTable: { ^['ID', 'Name'], [$'''''', $''''''] } DataTable=> SecondTable
    Variables.DeleteRowFromDataTable DataTable: SecondTable RowIndex: 0
    LOOP FOREACH CurrentItem IN FirstTable
     Variables.FindOrReplaceInDataTable.FindItemInDataTableByColumnIndex DataTable: SecondTable AllMatches: False ValueToFind: CurrentItem['ID'] MatchCase: False MatchEntireCellContents: False ColumnNameOrIndex: $'''ID''' DataTableMatches=> DataTableMatches
     IF DataTableMatches.RowsCount = 0 THEN
     Variables.AddRowToDataTable.AppendRowToDataTable DataTable: SecondTable RowToAdd: CurrentItem
     END
    END

     

  • Riyaz_riz11 Profile Picture
    4,214 Super User 2026 Season 1 on at

    Hi @nabeelamjad ,

     

    Try this, this will help you.

    Ahammad_Riyaz_1-1703220553341.png

     

     


    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    Regards,
    Riyaz

     

  • Verified answer
    Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @nabeelamjad 

     

    Another way to achieve this is by using Linq query using Run .Net script action.

     

    Assume you have a input datatable like below:

    Nived_Nambiar_0-1703266798235.png

     

    You need to remove duplicate columns based on column first /zero.

    Now use Run .NET Script action to run the GroupBy linq query 

     

    see below:

    Nived_Nambiar_1-1703266879637.png

     

    For field References to be uploaded, you have to pass the folder path where you have stored dll files for executing your script, for the details of the this,refer this article :

    https://www.linkedin.com/pulse/how-run-net-script-action-empowers-data-table-power-automate-bysani/

     

    2. Script paramters: specify the parameters that you need to pass in out of flow, see below:

    Nived_Nambiar_2-1703267005422.png

     

    3. Script: add the group by script like below:

    dt2= (From row in dt1.AsEnumerable()
    Group row by col= row(0).ToString Into Group
    Select Group.first()).CopyToDataTable()

     

    Now see the result :

    Nived_Nambiar_3-1703267057740.png

     

    Hope this helps !

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • Hidden Profile Picture
    2 on at

    After reading through the excel sheet and filtering out the data and use delete Duplicate rows from the data table action ensuring that all rows with identical data are deleted. Set the variable Var to 0.
    When comparing two rows within the same column using an if statement, remember that ['Name'] refers to the column name for which the values are being matched.

    Hidden_0-1719979053758.png

     

    I hope the above logic will help in deleting the rows that have the same value in a particular column.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 167

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard