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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Trim when filtering an...
Power Apps
Unanswered

Trim when filtering and delegation

(0) ShareShare
ReportReport
Posted on by 194
Hi Everyone,
I'm stumped and hoping you can help!
 
I have a power app that uses on prem sql database. I have a lookup table for locations in a table the app points to which is not changeable since it is shared with a legacy app. Because of the legacy system some of the data has a lot of extra spaces, here is an example:

"123 STREET  STREET      " --As you can see there is an extra space in the middle and trailing spaces at the end.
 
When I create a combobox to point to this table it seems the combobox removes these spaces innately because its displayed normal upon selection. My items code for the box is:
Distinct(Filter('HR.NA_LOCATION', NA_LOC_STATUS = "A"), NA_LOC_ADDRESS1)
But when I select the problem address in the combobox it removes the spaces and looks normal. Anyways, i have a secondary combobox that should show unit options based on the address selected in the first. This looks like this:
Distinct(Filter('HR.NA_LOCATION', NA_LOC_ADDRESS1 = ComboBox8.Selected.Value && NA_LOC_STATUS = "A"),NA_LOC_UNIT_NAME & " (" & NA_LOC_CODE & ")")
My issue right now is when I select the problematic (with spaces) address, the unit combobox is completely blank because its not finding a match. I assume its because power apps is fixing all the trailing and extra spaces in the first combobox.
 
I did get it working with the following code for the second combobox as below:
Distinct(Filter('HR.NA_LOCATION', Trim(NA_LOC_ADDRESS1) = ComboBox8.Selected.Value && NA_LOC_STATUS = "A"),NA_LOC_UNIT_NAME & " (" & NA_LOC_CODE & ")")
However now because I'm trimming in the middle of filtering I of course got the annoying delegation warning which wont do since there is much more than 2k records to sift through.
 
Please help!
 
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,335 Super User 2025 Season 2 on at
    Hi
     
    Yes I understand that stinks. there are a few ways, but here is one.
     
    Sorry Im having issues with the Code Snippet at the moment
     
    But change yours to do this
     
    With(
          { RecordsToFilter: Filter( 'HA.NA_LOCATION', NA_LOC_STATUS = "A")   },
     
          Distinct(Filter(RecordsToFilter, Trim(NA_LOC_ADDRESS1) = ComboBox8.Selected.Value), NA_LOC_UNIT_NAME & " (" & NA_LOC_CODE & ")")
     
    )
     
    This way your initial filter (hopefully you don't have more than 2000 that are A?????
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard