{"id":109223,"date":"2019-04-05T07:00:32","date_gmt":"2019-04-05T14:00:32","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/"},"modified":"2024-06-12T18:49:49","modified_gmt":"2024-06-13T01:49:49","slug":"delegation-enhancements-for-lookups-today-now-and-addcolumns","status":"publish","type":"power-apps","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/","title":{"rendered":"Delegation enhancements for lookups, Today\/Now, and AddColumns"},"content":{"rendered":"

I’m happy to announce we’ve made another batch of delegation enhancements for Canvas apps.<\/p>\n

Delegation refers to an app’s ability to “delegate” work to the data source instead of doing it locally, resulting in more scalable and higher performance apps.\u00a0 In short, Delegation = Good.\u00a0 For more details see\u00a0Understand delegation in a canvas app<\/a>.<\/p>\n

We are far from done with delegation.\u00a0 If you have suggestions on which queries and operations we should improve next please leave a comment or use the community forum<\/a>.<\/p>\n

Filter on lookup non-primary key fields<\/h2>\n

This one is specific to the Common Data Service.\u00a0 Until now we have only supported filtering an entity based on the primary key of a Many-to-One lookup.\u00a0 We can now filter based on other fields in the related entity, dramatically expanding the possibilities when working with lookups.<\/p>\n

For example, consider the following screen, built on top of the standard Accounts and Contacts entities:<\/p>\n

\"\"<\/p>\n

Note that there are no blue wavy lines or warning symbols – this formula is fully delagable.\u00a0 Let’s type a value in the text input box to perform our filtering:<\/p>\n

\"\"<\/p>\n

If we watch the network traffic from our app, and URL decode the query,\u00a0we see:<\/p>\n

$filter=(primarycontactid\/address1_city eq 'Issaquah')&$expand=primarycontactid<\/pre>\n

This is OData<\/a> speak for the formula we wrote with “primarycontactid” and “address1_city” being the logical names for our entity and column references in the formula.\u00a0 The IsBlank<\/strong><\/a> test does not appear here because it does not depend on data in the records being filtered and was handled before talking with the data source.<\/p>\n

We can also delegate the StartsWith<\/strong>\u00a0and EndsWith<\/strong><\/a> functions for our search:<\/p>\n

\"\"<\/p>\n

But we can’t yet delegate the\u00a0in<\/strong> operator, it is on our to-do list.\u00a0 Although definitely not the same, StartsWith<\/strong> can be used for many scenarios until we can delegate\u00a0in<\/strong>.<\/p>\n

Because these Filter<\/strong> calls can now be delegated, we can now search through millions of records and return the first page of results quickly with the ability to go back for more as the user scrolls through them in the gallery.<\/p>\n

Today and Now<\/h2>\n

In the lookup filter example above, the IsBlank<\/strong> test didn’t need to be delegated because it could be evaluated locally before going to the data source.\u00a0 We will be doing more of these optimizations over time.<\/p>\n

Case in point: we just added the Today<\/a><\/strong> and Now<\/a><\/strong> functions to the list of things we can do locally.\u00a0 For example, this filter of the Accounts entity:<\/p>\n

\"\"<\/p>\n

expands the Today function call into a constant to send to the data source:<\/p>\n

$filter=createdon ge 2019-04-01T16:16:03.013Z<\/pre>\n

Similarly, we already supported delegation for the Date<\/a> function:<\/p>\n

\"\"<\/p>\n

But, we don’t yet support constant folding with the DateAdd<\/a> function:<\/p>\n

\"\"<\/p>\n

We’re on it.<\/p>\n

AddColumns<\/h2>\n

Lots of people use the AddColumns<\/a><\/strong> function to bring in data from across data source, effectively performing heterogeneous joins.<\/p>\n

For example, imagine that you have a list of real estate agents in SharePoint and a table of home listings in SQL Server that contains tens of thousands of rows. You could combine this information with AddColumns<\/strong>:<\/p>\n

AddColumns( RealEstateAgents, \"Listings\",  Filter(  '[dbo].[AllListings]', ListingAgentName = AgentName ) )<\/pre>\n

Until now, AddColumns<\/strong> would not delegate the Filter<\/strong> call to SQL Server in the third argument and thus only the first 500 listings would have been searched.\u00a0 No longer, we can now delegate all the arguments of the\u00a0AddColumns <\/strong>function.<\/p>\n

But we aren’t done here yet. What we haven’t done is make the outside<\/em> of the AddColumns<\/strong>\u00a0delegable and pageable, the output\u00a0is still limited by the non-delegation limit.\u00a0 If for example you attach the result to a Gallery control through its Items property, it will be limited to 500 records.\u00a0 Something for our next installment.<\/p>\n

A word of caution on using\u00a0AddColumns<\/strong> in this manner.\u00a0 Each Filter<\/strong> call above is another round trip to the data source.\u00a0 \u00a0If performance is an issue, check the network activity in your browser to understand what is happening behind the scenes.\u00a0 If the number of related rows is small enough, you may want to bring them into a collection and do the filtering locally.\u00a0 You may also want to restructure your app to only grab the related records when a user specifically asks for them.\u00a0 \u00a0We can and will make this better in time, for example we could batch these calls for multiple rows to make this more efficient.<\/p>\n","protected":false},"excerpt":{"rendered":"

I’m happy to announce we’ve made another batch of delegation enhancements for Canvas apps. Delegation refers to an app’s ability to “delegate” work to the data source instead of doing it locally, resulting in more scalable and higher performance apps.\u00a0 In short, Delegation = Good.\u00a0 For more details see\u00a0Understand delegation in a canvas app. We<\/p>\n","protected":false},"author":86,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","power-apps-category":[1591,1617,1664],"power-apps-tag":[],"coauthors":[2332],"class_list":["post-109223","power-apps","type-power-apps","status-publish","hentry","power-apps-category-dataverse","power-apps-category-formulas","power-apps-category-uncategorized"],"yoast_head":"\nDelegation enhancements for lookups, Today\/Now, and AddColumns - Microsoft Power Platform Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Delegation enhancements for lookups, Today\/Now, and AddColumns - Microsoft Power Platform Blog\" \/>\n<meta property=\"og:description\" content=\"I’m happy to announce we’ve made another batch of delegation enhancements for Canvas apps. Delegation refers to an app’s ability to “delegate” work to the data source instead of doing it locally, resulting in more scalable and higher performance apps.\u00a0 In short, Delegation = Good.\u00a0 For more details see\u00a0Understand delegation in a canvas app. We\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft Power Platform Blog\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-13T01:49:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/powerappsblogmedia.azureedge.net\/powerappsblog\/2019\/03\/2019-03-31_17h36_48.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 min read\" \/>\n\t<meta name=\"twitter:label2\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data2\" content=\"Greg Lindhorst\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/\",\"name\":\"Delegation enhancements for lookups, Today\/Now, and AddColumns - Microsoft Power Platform Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/powerappsblogmedia.azureedge.net\/powerappsblog\/2019\/03\/2019-03-31_17h36_48.png\",\"datePublished\":\"2019-04-05T14:00:32+00:00\",\"dateModified\":\"2024-06-13T01:49:49+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#primaryimage\",\"url\":\"https:\/\/powerappsblogmedia.azureedge.net\/powerappsblog\/2019\/03\/2019-03-31_17h36_48.png\",\"contentUrl\":\"https:\/\/powerappsblogmedia.azureedge.net\/powerappsblog\/2019\/03\/2019-03-31_17h36_48.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Power Apps\",\"item\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Delegation enhancements for lookups, Today\/Now, and AddColumns\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/\",\"name\":\"Microsoft Power Platform Blog\",\"description\":\"Innovate with Business Apps\",\"publisher\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization\",\"name\":\"Microsoft Power Platform Blog\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png\",\"contentUrl\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png\",\"width\":194,\"height\":145,\"caption\":\"Microsoft Power Platform Blog\"},\"image\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Delegation enhancements for lookups, Today\/Now, and AddColumns - Microsoft Power Platform Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/","og_locale":"en_US","og_type":"article","og_title":"Delegation enhancements for lookups, Today\/Now, and AddColumns - Microsoft Power Platform Blog","og_description":"I’m happy to announce we’ve made another batch of delegation enhancements for Canvas apps. Delegation refers to an app’s ability to “delegate” work to the data source instead of doing it locally, resulting in more scalable and higher performance apps.\u00a0 In short, Delegation = Good.\u00a0 For more details see\u00a0Understand delegation in a canvas app. We","og_url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/","og_site_name":"Microsoft Power Platform Blog","article_modified_time":"2024-06-13T01:49:49+00:00","og_image":[{"url":"https:\/\/powerappsblogmedia.azureedge.net\/powerappsblog\/2019\/03\/2019-03-31_17h36_48.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 min read","Written by":"Greg Lindhorst"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/","name":"Delegation enhancements for lookups, Today\/Now, and AddColumns - Microsoft Power Platform Blog","isPartOf":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#primaryimage"},"image":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#primaryimage"},"thumbnailUrl":"https:\/\/powerappsblogmedia.azureedge.net\/powerappsblog\/2019\/03\/2019-03-31_17h36_48.png","datePublished":"2019-04-05T14:00:32+00:00","dateModified":"2024-06-13T01:49:49+00:00","breadcrumb":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#primaryimage","url":"https:\/\/powerappsblogmedia.azureedge.net\/powerappsblog\/2019\/03\/2019-03-31_17h36_48.png","contentUrl":"https:\/\/powerappsblogmedia.azureedge.net\/powerappsblog\/2019\/03\/2019-03-31_17h36_48.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/delegation-enhancements-for-lookups-today-now-and-addcolumns\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/"},{"@type":"ListItem","position":2,"name":"Power Apps","item":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/"},{"@type":"ListItem","position":3,"name":"Delegation enhancements for lookups, Today\/Now, and AddColumns"}]},{"@type":"WebSite","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/","name":"Microsoft Power Platform Blog","description":"Innovate with Business Apps","publisher":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization","name":"Microsoft Power Platform Blog","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png","contentUrl":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png","width":194,"height":145,"caption":"Microsoft Power Platform Blog"},"image":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/"}}]}},"msxcm_display_generated_audio":false,"distributor_meta":false,"distributor_terms":false,"distributor_media":false,"distributor_original_site_name":"Microsoft Power Platform Blog","distributor_original_site_url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog","push-errors":false,"_links":{"self":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-apps\/109223","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-apps"}],"about":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/types\/power-apps"}],"author":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/comments?post=109223"}],"version-history":[{"count":2,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-apps\/109223\/revisions"}],"predecessor-version":[{"id":109371,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-apps\/109223\/revisions\/109371"}],"wp:attachment":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/media?parent=109223"}],"wp:term":[{"taxonomy":"power-apps-category","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-apps-category?post=109223"},{"taxonomy":"power-apps-tag","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-apps-tag?post=109223"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/coauthors?post=109223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}