cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

delegation removal

Hi All,

i am using the below code for filtering my gallery, how do i remove delegation warning in it? The delegation warning comes around the or condition and around the &&. How can i remove the delegation?

If(
    Dropdown1.Selected.Result = "All Projects" && Dropdown1_1.Selected.Result = "All Projects" && IsBlank(statusvalue),
    SortByColumns(
        Filter(
            ITprojects,
            Or(
                (TextInput2.Text in 'Short Title'),
                (TextInput2.Text in Title),
                (TextInput2.Text in 'IT Lead'.DisplayName)
            ) && If(
                Value(from.SelectedDate) = 0,
                true,
                'Actual Start Date' >= from.SelectedDate && 'Actual Start Date' <= to.SelectedDate
            )
        ),
        "Created",
        Descending
    )

 


 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

@Anonymous ,

The Delegation Warning is on the in and Date Filters (none of these are Delegable) - firstly, please have a read of my blog on Delegation and it may explain the issue with a couple of workarounds. If your list will always have less than 2,000 items (and you have your limit set to this) , you can get rid of the warning with this (but it will only work on the first 2,000 items if the list grows bigger).

With(
   {
      wProjects:ITprojects,
      wText:TextInput2.Text
   },
   If(
      Dropdown1.Selected.Result = "All Projects" && 
      Dropdown1_1.Selected.Result = "All Projects" && 
      IsBlank(statusvalue),
      SortByColumns(
         Filter(
            wProjects,
            (
               wText in 'Short Title' ||
               wText in Title ||
               wText in 'IT Lead'.DisplayName
            ) && 
            ( 
               Value(from.SelectedDate) = 0 || 
               (
                  'Actual Start Date' >= from.SelectedDate && 
                  'Actual Start Date' <= to.SelectedDate
               )
            )
         ),
         "Created",
         Descending
      )
   )
)

There are some other filters rather than in if you are looking for an exact match - use StartsWith(), but Date queries are not Delegable.
If StartsWith() will work, you can do this

If(
   Dropdown1.Selected.Result = "All Projects" && 
   Dropdown1_1.Selected.Result = "All Projects" && 
   IsBlank(statusvalue),
   With(
      {
         wProjects:
         Filter(      
            ITprojects,
            StartsWith('Short Title',TextInput2.Text)  ||
            StartsWith(Title, TextInput2.Text) ||
            StartsWith('IT Lead'.DisplayName, TextInput2.Text)
         )
      },
      SortByColumns(
         Filter(
            wProjects, 
            ( 
               Value(from.SelectedDate) = 0 || 
               (
                  'Actual Start Date' >= from.SelectedDate && 
                  'Actual Start Date' <= to.SelectedDate
               )
            )
         ),
         "Created",
         Descending
      )
   )
)

 

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.

View solution in original post

2 REPLIES 2
WarrenBelz
Super User
Super User

@Anonymous ,

The Delegation Warning is on the in and Date Filters (none of these are Delegable) - firstly, please have a read of my blog on Delegation and it may explain the issue with a couple of workarounds. If your list will always have less than 2,000 items (and you have your limit set to this) , you can get rid of the warning with this (but it will only work on the first 2,000 items if the list grows bigger).

With(
   {
      wProjects:ITprojects,
      wText:TextInput2.Text
   },
   If(
      Dropdown1.Selected.Result = "All Projects" && 
      Dropdown1_1.Selected.Result = "All Projects" && 
      IsBlank(statusvalue),
      SortByColumns(
         Filter(
            wProjects,
            (
               wText in 'Short Title' ||
               wText in Title ||
               wText in 'IT Lead'.DisplayName
            ) && 
            ( 
               Value(from.SelectedDate) = 0 || 
               (
                  'Actual Start Date' >= from.SelectedDate && 
                  'Actual Start Date' <= to.SelectedDate
               )
            )
         ),
         "Created",
         Descending
      )
   )
)

There are some other filters rather than in if you are looking for an exact match - use StartsWith(), but Date queries are not Delegable.
If StartsWith() will work, you can do this

If(
   Dropdown1.Selected.Result = "All Projects" && 
   Dropdown1_1.Selected.Result = "All Projects" && 
   IsBlank(statusvalue),
   With(
      {
         wProjects:
         Filter(      
            ITprojects,
            StartsWith('Short Title',TextInput2.Text)  ||
            StartsWith(Title, TextInput2.Text) ||
            StartsWith('IT Lead'.DisplayName, TextInput2.Text)
         )
      },
      SortByColumns(
         Filter(
            wProjects, 
            ( 
               Value(from.SelectedDate) = 0 || 
               (
                  'Actual Start Date' >= from.SelectedDate && 
                  'Actual Start Date' <= to.SelectedDate
               )
            )
         ),
         "Created",
         Descending
      )
   )
)

 

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.

v-bofeng-msft
Community Support
Community Support

Hi @Anonymous :

Firstly,let me explain why you encountered delegation error.

The point is that "in" is not delegable.I think this link will help you a lot:

Power Apps delegable functions and operations for SharePoint 

Secondly,maybe you could try:

If(
    Dropdown1.Selected.Result = "All Projects" && Dropdown1_1.Selected.Result = "All Projects" && IsBlank(statusvalue),
    SortByColumns(
        Filter(
            ITprojects,
            Or(
                (TextInput2.Text = 'Short Title'),
                (TextInput2.Text = Title),
                (TextInput2.Text = 'IT Lead'.DisplayName)
            ) && If(
                Value(from.SelectedDate) = 0,
                true,
                'Actual Start Date' >= from.SelectedDate && 'Actual Start Date' <= to.SelectedDate
            )
        ),
        "Created",
        Descending
    )

Best Regards,

Bof

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,954)