Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Search filter issue

Like (1) ShareShare
ReportReport
Posted on 1 Oct 2024 18:20:47 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 144,316 on 03 Oct 2024 at 21:17:18
    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 03 Oct 2024 at 13:42:21
    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 29,371 on 03 Oct 2024 at 02:43:21
    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 02 Oct 2024 at 14:17:32
    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 144,316 on 01 Oct 2024 at 22:20:00
    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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 144,316

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,290

Leaderboard
Loading started
Loading complete