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 Apps / Remove duplicate rows ...
Power Apps
Unanswered

Remove duplicate rows from Gallery querying from a SQL database

(0) ShareShare
ReportReport
Posted on by 101

I want to filter data in a gallery connected to a SQL database by the City column using a text input.  Then I want to enter the City in the text input and then populate all the Zip Codes in that City, along with data from the remaining columns.

 

The columns that are querying from a SQL database are: Zip Code, House Number, Street Name, and City.  This is what I'm seeing when I enter this code: 

 

Sort(Filter(sqlDatabase,StartsWith('City',searchInput.Text)),Zip Code,SortOrder.Descending)

 

Zip CodeHouse NumberStreet NameCity
78451456Holmes AveChicago
78451456Holmes AveChicago
78451456Holmes AveChicago
784694895Richard St.Chicago
784694895Richard St.Chicago
784662387Harwich AveChicago
784662387Harwich AveChicago
784662387Harwich AveChicago
784662387Harwich AveChicago
7848165Birdeye LaneChicago
7848165Birdeye LaneChicago
7843556224 W 14thChicago

It's pulling in duplicates.  I want to remove the duplicates. 

 

I would like the gallery in my Power Apps form to show the following when I filter by City:

Zip CodeHouse NumberStreet NameCity
78451456Holmes AveChicago
784694895Richard St.Chicago
784662387Harwich AveChicago
7848165Birdeye LaneChicago
7843556224 W 14thChicago

As you can see the duplicates are not there.

 

I know that I cannot use the Distinct function because it will only return the values of one column.  

 

Is there a formula I can use to remove the duplicates when filtering by city as shown in the second table? 

 

Any advice can help.  Thanks! 

Categories:
  • WarrenBelz Profile Picture
    156,530 Most Valuable Professional on at

    Hi @MicroMarc365 ,

    Use the GroupBy function - the last grouped column Data needs to be there but is not relevant here

    Sort(
     GroupBy(
     Filter(
     sqlDatabase,
     StartsWith(
     'City',
     searchInput.Text
     )
     ),
     "Zip Code",
     "House Number",
     "Street Name",
     "City",
     "Data"
     ),
     Zip Code,
     SortOrder.Descending
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • MicroMarc365 Profile Picture
    101 on at

    Unfortunately, it's still populating duplicate rows.  I did notice when I type in the column_name the data type is returning as text.  

  • WarrenBelz Profile Picture
    156,530 Most Valuable Professional on at

    @MicroMarc365 ,

    Are the duplicates across all 4 columns (they should not be with GroupBy)

  • MicroMarc365 Profile Picture
    101 on at

    They are duplicates across all 4 columns

  • WarrenBelz Profile Picture
    156,530 Most Valuable Professional on at

    @MicroMarc365 

    I will rephase that for clarity - you have records that are identical in all column values and when you use GroupBy as I posted, you have duplicates in the output ? If so, that is contrary to the purpose of the function and should not happen. I just ran a test here and received the expected result. Can you please post (in Text) the code you are using and a screenshot of the duplicates.

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard