Skip to main content

Notifications

Building Power Apps
Answered

Search filter issue

Posted on by 8
   Filter(
    [@'DB'],
    (StartsWith(FirstName, SearchInput1.Text) ||
     StartsWith(LastName, SearchInput1.Text) ||
     StartsWith(Text(EmployeeID), SearchInput1.Text))
)
 
 
This is my code for the filter. I am receiving a delegation warning;
I've made the suggested changes by changing the data limit.
Not sure what else to do, and I am having no luck with any other variations of the current filter I have to display what I want.
  • WarrenBelz Profile Picture
    WarrenBelz 141,157 on at
    Search filter issue
    UnfortunatelyFLMike's suggestion will not work with the With() statement referring to a field inside the filter (the With is run first and has no idea what you are referring to). You can do it like this, but not in a Delegable manner (you will not get a warning, but the AddColumns output is restricted by your Data Row Limit
    Filter(
       AddColumns(    
          [@'DB'],
          IDTxt,
          Text(EmployeeID)
       ),
       StartsWith(FirstName, SearchInput1.Text) ||
       StartsWith(LastName, SearchInput1.Text) ||
       StartsWith(IDTxt, SearchInput1.Text)
    )
    
    However, the weird thing here is that that code I posted should technically work (it is simply three valid Delegable filters separated by Or || ), but testing here results in what you have posted. So the code below is a complete unnecessary workaround for what seems a bug, but works as intended
    If(
       IsNumeric(SearchInput1.Text),
       Filter(
          [@'DB'],
          EmployeeID = Value(SearchInput1.Text)
       ),
       Filter(
          [@'DB'],
          StartsWith(
             FirstName,
             SearchInput1.Text
          ) || 
    ​​​​​​​ StartsWith( LastName, SearchInput1.Text ) ) )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee
  • DY-26072043-0 Profile Picture
    DY-26072043-0 8 on at
    Search filter issue
    I really appreciate all of the help and knowledge so far. The solution Warren provided worked to an extent, but did not allow anything from firstname/lastname columns to return with results, it only allowed employeeID's (numerical). I've tried FLMike's solution and I'm getting an error. here it is
     
  • Verified answer
    FLMike Profile Picture
    FLMike 26,453 on at
    Search filter issue
    I want to add 1 thing
     
    But you mentioned making the data limit change., THe data limit change doesn't have any impact on Delegation except to say that it will allow more records.
     
    The delegation warning wont go away regardless of whether you put 1 or 2000, Its not relevant to the warning.

    As Warren mentioned it is the reason so you can try this (and this is a Warren special. if i do it correctly) so his answer is also the answer.

    With(
           {ConvertedEmployeeId: Text(EmployeeID)   },

       Filter(
        [@'DB'],
        (StartsWith(FirstName, SearchInput1.Text) ||
         StartsWith(LastName, SearchInput1.Text) ||
         StartsWith(ConvertedEmployeeId, SearchInput1.Text))
       )
    )

    Or you can leave exactly what Warren has, but I believe what you meant to do is something like this


  • DY-26072043-0 Profile Picture
    DY-26072043-0 8 on at
    Search filter issue
    Thank you! That got rid of the delegation warning. Unfortunately, the first and last name part of the search doesn't seem to work now. 
  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 141,157 on at
    Search filter issue
    The issue is that a field type conversion inside a filter is not Delegable (you are using Text(EmployeeID)). I assume here that EmployeeID is numeric, so the best you will do is (meaning the complete EmployeeID would need to be entered)
    Filter(
       [@'DB'],
       StartsWith(FirstName, SearchInput1.Text) ||
       StartsWith(LastName, SearchInput1.Text) ||
       EmployeeID = Value(SearchInput1.Text)
    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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

September 2024 Newsletter…

September 2024 Community Newsletter…

Community Update Sept 16…

Power Platform Community Update…

Welcome to the new Power Platform Community!…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 141,157

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,414

Leaderboard