Skip to content

Power Apps

Remove Duplicate Rows From A Power Apps Collection

Remove Duplicate Rows From A Power Apps Collection Posted by - Matthew Devaney on - July 31, 2022 32 Comments Remove the duplicate rows from any Power Apps c...

Matthew Devaney
Published
Reading time
2 min read

Before you start

Is this guide for you?

Best entry point
Power Apps
Time investment
2 min read

Imported reference from Matthew Devaney's blog for learning purposes. Original: https://www.matthewdevaney.com/remove-duplicate-rows-from-a-power-apps-collection/. Author: Matthew Devaney.

Remove Duplicate Rows From A Power Apps Collection Posted by - Matthew Devaney on - July 31, 2022 32 Comments

Remove the duplicate rows from any Power Apps collection with this 1 line of code. //Duplicate removal code

ClearCollect(colSolution, ForAll(Distinct(yourCollectionName, ThisRecord), Result)); Code language: JavaScript ( javascript ) Here’s how it works:

The Distinct function returns a one-column table of unique values for a field. But when we use ThisRecord instead of a column name it results in a one-column table of unique records. Then we loop over the one column table using ForAll to extract the rows into a multliple column table.

For more help with collections check out my Power Apps Collections Cookbook . There are over 50 examples and code you can copy + paste into your own apps. Full Example : Remove Duplicate Rows Input Collection

Start with this Power Apps collection named colVehicles . Year Make Model 2020 Ford F150 2018 Chevy Silverado 2020 Ford F150 2020 Ford F150 2017 Nissan Frontier 2016 GM Yukon 2016 GM Yukon Output Collection

Our goal is to remove the duplicate rows from the Power Apps collection colVehicles and achieve this result. Year Make Model 2020 Ford F150 2018 Chevy Silverado 2017 Nissan Frontier 2016 GM Yukon Solution Code

Use this code to remove the duplicate rows from colVehicles . //Create a collection

ClearCollect(colVehicles, { Year : 2020 , Make : "Ford" , Model : "F150" }, { Year : 2018 , Make : "Chevy" , Model : "Silverado" }, { Year : 2020 , Make : "Ford" , Model : "F150" }, { Year : 2020 , Make : "Ford" , Model : "F150" }, { Year : 2017 , Make : "Nissan" , Model : "Frontier" }, { Year : 2016 , Make : "GM" , Model : "Yukon" }, { Year : 2016 , Make : "GM" , Model : "Yukon" } ); //Duplicate removal code

ClearCollect(mySolution, ForAll(Distinct(colVehicles, ThisRecord), Result)); Code language: JavaScript ( javascript ) Did You Enjoy This Article? 😺

Subscribe to get new Copilot Studio articles sent to your inbox each week for FREE Enter your email address Sign Me Up Questions?

If you have any questions about Remove Duplicate Rows From A Power Apps Collection please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion. Matthew Devaney M365 Copilot Power Apps

How To Create Copilot Custom UI Widgets In Power Apps

Share this

Tagged

Collections · Power Apps

Have a Microsoft 365 topic idea?

Share article suggestions, community session ideas, corrections, or real-world scenarios for future nextM365 learning notes.

Suggest a topic

Keep learning Microsoft 365

Explore more practical guides for SharePoint, Power Platform, Copilot Studio, migration, automation, governance, and security.

Continue learning

Next action

What to do next

Browse all tutorials →