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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to use With and Se...
Power Apps
Answered

How to use With and Search function with an If condition

(0) ShareShare
ReportReport
Posted on by

Hi,

 

I'm trying to use the Search using the With as given in this blog https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/With-Statement-to-include-non-Delegable-filters/ba-p/660997 by @WarrenBelz .

 

Having some issue since my Filter will change based on User . How to add the If condition to change the Filter 

 

If
(
 selectedNavItem = 2,
 SortByColumns(
 Filter(
 SPLIST, 
 RequesterDepartment=LogInUserDept),
 StartsWith(RequestTitle, searchInput.Text) || 
 StartsWith(RequesterFullName, searchInput.Text) || 
 IsBlank(searchInput.Text)),
 "ID", Descending),
 
 	selectedNavItem = 3, 
	 SortByColumns( 
	 Filter(
 SPLIST, 
 RequesterEmail=LogInUserMail,
 StartsWith(RequestTitle, searchInput.Text)|| 
 IsBlank(searchInput.Text)), 
	 "ID", Descending) 
	 
)

  I tried adding like below and I know it is not correct. 

With(
 If(selectedNavItem = 2,
 {
 MyFilter: 
 Filter(
 SPList,
 Department=LogInUserDept),
 
	},
	selectedNavItem = 3,
	{
 MyFilter: 
 Filter(
 SPList,
 Email=LogInUserMail),
 
	}
	),	
	
 Search(
 MyFilter,
 searchInput.Text,
 "FullName",
	 "Title"
 )
)

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    Hi @indhaa .

    I am assuming the only choices for selectedNavItem are 2 and 3?

    With(
     {
     MyFilter: 
     Filter(
     SPList,
     If(
     selectedNavItem = 2,
     Department=LogInUserDept,
     Email=LogInUserMail
     )
     )
     },
     Search(
     MyFilter,
     searchInput.Text,
     "FullName",
     "Title"
     )
    )

     

    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.

    Visit my blog Practical Power Apps

  • indhaa Profile Picture
    on at

    I'm getting delegation warning on it. 

     

    indhaa_0-1637318682226.png

     

  • Verified answer
    WarrenBelz Profile Picture
    156,384 Most Valuable Professional on at

    @indhaa ,

    A step back

    With(
     {
     MyFilter: 
     If(
     selectedNavItem = 2,
     Filter(
     SPList,
     Department=LogInUserDept
     ),
     Filter(
     SPList,
     Email=LogInUserMail
     )
     )
     },
     Search(
     MyFilter,
     searchInput.Text,
     "FullName",
     "Title"
     )
    )

    You are also going to have to accept at times that you simply cannot do everything you want to do in a Delegable manner.

     

    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.

    Visit my blog Practical Power Apps

     

  • indhaa Profile Picture
    on at

    Yah, I don't think I will be able to use it.

     

    Your above code is delegable but I need to add more condition which will not be delegable, so going to stick with my old code.

     

    Thanks for the help

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard