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
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PWREduCon768x460.png

Join us at PWR EduCon - A Power Platform Conference

Learn from the top Power BI, Power Apps, Power Automate & Power Virtual Agents experts!

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