Introduction
With function is one that I tried not to use for a very long time. Why? I actually don't have a reason for it. I probably just never realized its true worth. One of the advantages was that it helps resolve delegation issues. Is that really true though?
Delegation issue without With
To figure this out, let's take the example of two tables - Instructors and Courses. The Courses table has a lookup to the Instructors table. Let's say, we want to lookup an instructor and then filter the list of courses that are assigned to that instructor.
A code like this works but is not delegable:
Filter(
Courses,
Instructor.Name = LookUp(
[@Instructors],
Name = "Misha Bhatia"
).Name
)
Here is the infamous blue squiggly line:
Is With function really delegable?
To fix this, a lot of makers would change the code to this:
With(
{
varInstructorName: LookUp(
Instructors,
Name = "Misha Bhatia"
).Name
},
Filter(
Courses,
Instructor.Name = varInstructorName
)
)
As you can see below, there is no blue squiggly line. So you get the impression that your formula is now delegable.
To test if the With function is really delegable or not, change the non-delegation limit to 1 (in app settings). Here is a quick demo:
To learn more about delegation, click here.
Stay tuned for the remaining 3 tips!
Hi Hardit,
Function itself as you point out is subject to Delegation in regards to the output, but it will action a Delegable filter inside it and pre-filter the result to less than your limit, so that a non-delegable action can be done on this output.