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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / LookUp inside filter f...
Power Apps
Unanswered

LookUp inside filter function is giving delegation error

(0) ShareShare
ReportReport
Posted on by 14

Hello all,

 

 I am trying to apply filters on the gallery. One such filter is to get tasks updated between starttime and endtime. 

Filter(
	Tasks As rtTask,
	rtTask.Tasktype = "MainTask",
	rtTask.TaskHours <= 0,
	LookUp(subTaskTable,TaskId.TaskId = rtTask.TaskId).updateTime >= varshiftTime && 
 LookUp(subTaskTable,TaskId.TaskId = rtTask.TaskId).updateTime <= varshiftTimeEnd,
 rtTask.TaskName in systemTaskColl
)

 The lookup inside filter function is giving me delegation warning. Is there any alternate approach to make this work? Thank you.

Categories:
I have the same question (0)
  • VaidasG Profile Picture
    469 on at

    Hi @SAGOS_12,

     

    try moving your lookups outside of the filter and set it's values as variables:

    Set(var1, LookUp(subTaskTable,TaskId.TaskId = rtTask.TaskId).updateTime),
    Set(var2, LookUp(subTaskTable,TaskId.TaskId = rtTask.TaskId).updateTime)

     then use these values for your filtering

     

    Regards
    VaidasG

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • SAGOS_12 Profile Picture
    14 on at

    Thanks for the response. Not sure how this gonna help, let me elaborate.

    Main Task table:

    TaskIDTaskNameTaskTypeTaskHours
    Task01testMainTask5
    Task02test22MainTask10

    Sub Task Table: It has lookup column to the main task table.

    SubTaskIDTaskIDUpdateTime
    sub01Task015/10/2023 10:00 AM
    sub02Task023/25/2023 1:00 AM

    Now on Items property on Gallery to show main Task table:

     

    Filter(
    	Tasks As rtTask,
    	rtTask.Tasktype = "MainTask",
    	rtTask.TaskHours <= 0,
    	FilterShift.Value = false Or (LookUp(subTaskTable,TaskId.TaskId = rtTask.TaskId).updateTime >= varshiftTime && 
     LookUp(subTaskTable,TaskId.TaskId = rtTask.TaskId).updateTime <= varshiftTimeEnd),
     rtTask.TaskName in systemTaskColl
    )

     

     When a toggle (FilterShift) is selected:

    varShiftTime is set to 5/09/2023 11 AM and varShiftTimeEnd is set to 5/10/2023 11 AM. Since 'sub01' falls under this time, 

    Gallery should show only one item - Task01.

     

    But the above filter formula is giving delegation due to lookup function. Any idea how to correct this?

  • SAGOS_12 Profile Picture
    14 on at

    @WarrenBelz 

    Hi, could you please help me on this one.

  • Verified answer
    WarrenBelz Profile Picture
    153,040 Most Valuable Professional on at

    Hi @SAGOS_12 ,

    You are not going to get that completely Delegable if you are referring to a field in the Data Source being queried. Also you did not state your data source, but if it is SharePoint, you also have an in filter there which is not Delegable - this is the best I believe you can do (which may be adequate)

    With(
     {
     wData:
     Filter(
     Tasks,
     Tasktype = "MainTask" &&
     TaskHours <= 0
     )
     },
     Filter(
     AddColumns(
     wData,
     "UDTime"
     LookUp(
     subTaskTable as aSub,
     aSub.TaskId = TaskId
     ).updateTime
     ),
     UDTime >= varshiftTime && 
     UDTime <= varshiftTimeEnd &&
     TaskName in systemTaskColl
     )
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • SAGOS_12 Profile Picture
    14 on at

    Thank you @WarrenBelz . It helped me to look at writing formula in different perspective. Appreciate it.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard