Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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:
  • Suggested answer
    Michael E. Gernaey Profile Picture
    40,887 Super User 2025 Season 1 on at
    Trim when filtering and delegation
    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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,618 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,962 Most Valuable Professional

Leaderboard