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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,246)