{"id":34461,"date":"2023-04-17T14:24:04","date_gmt":"2023-04-17T08:54:04","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=34461"},"modified":"2024-01-04T12:23:57","modified_gmt":"2024-01-04T06:53:57","slug":"how-to-filter-json-array-using-filter-array-action-in-power-automate","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2023\/04\/how-to-filter-json-array-using-filter-array-action-in-power-automate\/","title":{"rendered":"How to filter JSON array using Filter Array action in Power Automate"},"content":{"rendered":"<p>A requirement of filtering JASON arrays can easily be solved using JavaScript. But to do it in <a href=\"https:\/\/www.inogic.com\/services\/microsoft-power-platform\/microsoft-power-automate\/\">Power Automate<\/a>, we have to create a web resource and register the script in CRM. However, with the new updates, we can achieve this requirement within the CRM process itself. Power Automate introduced the Filter Array action, using which we can easily filter the JSON array of objects and get the exact output from the JSON array.<\/p>\n<p><strong>Requirement:<\/strong><\/p>\n<p>Consider that we have JSON data containing individual Employee\u2019s Project Details which specify the number of projects that a single employee is working on, the number of projects completed, the estimation of the projects in days, and their start date. Please find below the JSON array that we want to filter:<\/p>\n<pre class=\"lang:css gutter:true start:1\">{\r\n\r\n{\r\n\r\n\"Project Name\": \"Employee Payroll System\",\r\n\r\n\"Start Date\": \"22-05-2021\",\r\n\r\n\"Duration\": 65,\r\n\r\n\"Industry\": \"IT Corporate\",\r\n\r\n\"Status\": \"Complete\"\r\n\r\n},\r\n\r\n{\r\n\r\n\"Project Name\": \"Healthcare Solution\",\r\n\r\n\"Start Date\": \"22-03-2023\",\r\n\r\n\"Duration\": 95,\r\n\r\n\"Industry\": \"Heath and Hospitality\",\r\n\r\n\"Status\": \"In Progress\"\r\n\r\n},\r\n\r\n{\r\n\r\n\"Project Name\": \"Pharmacare Solution\",\r\n\r\n\"Start Date\": \"26-03-2022\",\r\n\r\n\"Duration\": 32,\r\n\r\n\"Industry\": \"Heath and Hospitality\",\r\n\r\n\"Status\": \"Complete\"\r\n\r\n},\r\n\r\n{\r\n\r\n\"Project Name\": \"Agro Management System\",\r\n\r\n\"Start Date\": \"22-08-2021\",\r\n\r\n\"Duration\": 120,\r\n\r\n\"Industry\": \"Agriculture\",\r\n\r\n\"Status\": \"Complete\"\r\n\r\n},\r\n\r\n{\r\n\r\n\"Project Name\": \"Finance Management System\",\r\n\r\n\"Start Date\": \"22-08-2023\",\r\n\r\n\"Duration\": 38,\r\n\r\n\"Industry\": \"Finance\",\r\n\r\n\"Status\": \"Not Started\"\r\n\r\n}\r\n\r\n}<\/pre>\n<p>In the above JSON array, they mention project details for five projects. So, now we want to identify how many projects an individual employee has completed for a duration greater than 40.<\/p>\n<h2><strong>Solution<\/strong><\/h2>\n<p>For this requirement, we go with the Power Automate solution. We have created an on-demand Power Automate flow. In that we have passed the above JSON array as an input as shown in the following screenshot:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-34463\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/1Filter-Array-action-in-Power-Automate.jpeg\" alt=\"Filter Array action in Power Automate\" width=\"1361\" height=\"643\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/1Filter-Array-action-in-Power-Automate.jpeg 1361w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/1Filter-Array-action-in-Power-Automate-300x142.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/1Filter-Array-action-in-Power-Automate-1024x484.jpeg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/1Filter-Array-action-in-Power-Automate-768x363.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/1Filter-Array-action-in-Power-Automate-660x312.jpeg 660w\" sizes=\"(max-width: 1361px) 100vw, 1361px\" \/><\/p>\n<p>Next, we apply the Filter Array action on the above input of the JSON array<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-34464\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/2Filter-Array-action-in-Power-Automate.jpeg\" alt=\"Filter Array action in Power Automate\" width=\"1363\" height=\"639\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/2Filter-Array-action-in-Power-Automate.jpeg 1363w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/2Filter-Array-action-in-Power-Automate-300x141.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/2Filter-Array-action-in-Power-Automate-1024x480.jpeg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/2Filter-Array-action-in-Power-Automate-768x360.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/2Filter-Array-action-in-Power-Automate-660x309.jpeg 660w\" sizes=\"(max-width: 1363px) 100vw, 1363px\" \/><\/p>\n<p>Following is the Filter Array expression that we have used to get the exact output:<\/p>\n<p><strong><em>@and(equals(item().Status,\u2019Complete\u2019),greater(item().Duration,40))<\/em><\/strong><\/p>\n<p>Here we have applied both conditions which we have merged with the\u00a0<strong><em>@and<\/em>\u00a0<\/strong>clause. In that,<\/p>\n<p><a href=\"https:\/\/bit.ly\/43AEpmS\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"alignnone wp-image-34467\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/Microsoft-Power-Platform.gif\" alt=\"Microsoft Power Platform\" width=\"1016\" height=\"254\" \/><\/a><\/p>\n<p>1. The projects which were completed, were obtained using the <strong><em>@equals<\/em><\/strong> clause<\/p>\n<p><strong><em>equals(item().Status,&#8217;Complete&#8217;)<\/em><\/strong><\/p>\n<p>2. The projects which have not been completed within 40 days, were obtained using the <strong>@greater<\/strong><\/p>\n<p><strong><em>greater(item().Duration,40)<\/em><\/strong><\/p>\n<p>After applying the Filter Array action we got the exact output as shown in the screenshot below:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-34465\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/3Filter-Array-action-in-Power-Automate.jpeg\" alt=\"Filter Array action in Power Automate\" width=\"1365\" height=\"673\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/3Filter-Array-action-in-Power-Automate.jpeg 1365w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/3Filter-Array-action-in-Power-Automate-300x148.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/3Filter-Array-action-in-Power-Automate-1024x505.jpeg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/3Filter-Array-action-in-Power-Automate-768x379.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/04\/3Filter-Array-action-in-Power-Automate-660x325.jpeg 660w\" sizes=\"(max-width: 1365px) 100vw, 1365px\" \/><\/p>\n<h2>Conclusion<\/h2>\n<p><strong>Filter Array<\/strong>\u00a0is the best option to filter the JSON array in Power Automate without writing any external programming logic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A requirement of filtering JASON arrays can easily be solved using JavaScript. But to do it in Power Automate, we have to create a web resource and register the script in CRM. However, with the new updates, we can achieve this requirement within the CRM process itself. Power Automate introduced the Filter Array action, using\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2023\/04\/how-to-filter-json-array-using-filter-array-action-in-power-automate\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1913,1985,2361],"tags":[2689,1975],"class_list":["post-34461","post","type-post","status-publish","format-standard","hentry","category-microsoft-power-platform-services","category-power-automate","category-technical","tag-json-array","tag-power-automate"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/34461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=34461"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/34461\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=34461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=34461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=34461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}