cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
brucegil1
Frequent Visitor

Startswith Function Returns Unwanted Records

I have a Power Apps gallery connected to a SharePoint list called "TestPoints".  Each record in the TestPoints list has a unique identifier beginning with the prefix "Subject" followed by a number, for example "Subject599". The list contains multiple records with the same identifier.  The record identifiers are stored under the list column "TestSubjectNumber".  I  use a combox to select the records to populate the screen’s gallery by the record’s identifier. The formula I have been using in the gallery’s item property is:

 

SortByColumns(Filter([@TestPoints], StartsWith(TestSubjectNumber, First(ComboBox.SelectedItems).TestSubjectNumber)), "TestSubjectNumber", If(SortDescending1, Descending, Ascending)

 

The problem concerns the “StartsWtih” function in the formula.  For example, instead of returning all the records  with the identifier “Subject599”, the gallery is populated with all the records with identifiers that start with “Subjet5…”  In other words, the “StartsWith” function returns records  with identifiers Subject500, Subject501 etc. I have tried in the formula to replace the “StartsWith” function with the “Search” function, but in doing so no records are returned.  How should the formula be written so that only the records with the unique identifier are returned to populate the gallery.  TIA.   

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @brucegil1 ,

Assuming this is a single-select combo box, this should work

SortByColumns(
   Filter(
      [@TestPoints], 
      StartsWith(
         TestSubjectNumber, 
         ComboBox.Selected.TestSubjectNumber
      )
   ),
   "TestSubjectNumber", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

however I am a little concerned you are looking in the same field name in the data suggesting they may equal rather than return a series of records.

 

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.

View solution in original post

2 REPLIES 2
WarrenBelz
Super User
Super User

Hi @brucegil1 ,

Assuming this is a single-select combo box, this should work

SortByColumns(
   Filter(
      [@TestPoints], 
      StartsWith(
         TestSubjectNumber, 
         ComboBox.Selected.TestSubjectNumber
      )
   ),
   "TestSubjectNumber", 
   If(
      SortDescending1, 
      Descending, 
      Ascending
   )
)

however I am a little concerned you are looking in the same field name in the data suggesting they may equal rather than return a series of records.

 

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.

View solution in original post

Warren, thank you for your solution.  I appreciate your help

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,627)