<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: JaganReddyK</title>
    <description>The latest articles on DEV Community by JaganReddyK (@jaganjrai).</description>
    <link>https://dev.to/jaganjrai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4046008%2F2c37eb93-c93a-4dde-968d-4d14b3e40e87.jpg</url>
      <title>DEV Community: JaganReddyK</title>
      <link>https://dev.to/jaganjrai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jaganjrai"/>
    <language>en</language>
    <item>
      <title>You're Probably Overusing "Apply to each" in Power Automate</title>
      <dc:creator>JaganReddyK</dc:creator>
      <pubDate>Tue, 28 Jul 2026 04:47:47 +0000</pubDate>
      <link>https://dev.to/jaganjrai/youre-probably-overusing-apply-to-each-in-power-automate-3mlh</link>
      <guid>https://dev.to/jaganjrai/youre-probably-overusing-apply-to-each-in-power-automate-3mlh</guid>
      <description>&lt;p&gt;When I started building Power Automate solutions, my answer to almost every array was the same:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use "Apply to each."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It worked. My flows ran successfully, and I moved on.&lt;/p&gt;

&lt;p&gt;But as projects became larger, I noticed a pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flows took longer to execute.&lt;/li&gt;
&lt;li&gt;Action counts kept increasing.&lt;/li&gt;
&lt;li&gt;Debugging became painful.&lt;/li&gt;
&lt;li&gt;Simple tasks required dozens of actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's when I started looking for ways to simplify my flows—and XPath became one of my favorite techniques for working with XML.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Imagine receiving an XML response with hundreds of employee records.&lt;/p&gt;

&lt;p&gt;If you only need &lt;strong&gt;one employee's name&lt;/strong&gt;, should your flow really loop through every record?&lt;/p&gt;

&lt;p&gt;Probably not.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Better Approach
&lt;/h2&gt;

&lt;p&gt;XPath lets you query XML directly.&lt;/p&gt;

&lt;p&gt;Instead of saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Check every employee until you find ID 102."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You simply ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Give me the employee whose ID is 102."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The expression looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;```text id="m8t2p4"&lt;br&gt;
xpath(&lt;br&gt;
xml(outputs('Compose')),&lt;br&gt;
'/Employees/Employee[Id="102"]/Name/text()'&lt;br&gt;
)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


The result?



```text id="w5c6y1"
David
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it.&lt;/p&gt;

&lt;p&gt;No loop.&lt;/p&gt;

&lt;p&gt;No condition.&lt;/p&gt;

&lt;p&gt;Just the data you need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;p&gt;Using XPath can help you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce unnecessary actions&lt;/li&gt;
&lt;li&gt;Improve execution speed&lt;/li&gt;
&lt;li&gt;Simplify maintenance&lt;/li&gt;
&lt;li&gt;Build cleaner enterprise automation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's a small optimization, but when applied across dozens of production flows, the impact adds up.&lt;/p&gt;

&lt;h2&gt;
  
  
  When to Use XPath
&lt;/h2&gt;

&lt;p&gt;XPath is ideal when you're working with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;XML files&lt;/li&gt;
&lt;li&gt;SOAP APIs&lt;/li&gt;
&lt;li&gt;XML responses from legacy systems&lt;/li&gt;
&lt;li&gt;SharePoint XML payloads&lt;/li&gt;
&lt;li&gt;Structured XML documents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your data is JSON, Power Automate already provides excellent functions such as &lt;code&gt;filter()&lt;/code&gt;, &lt;code&gt;select()&lt;/code&gt;, and &lt;code&gt;first()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Choose the right tool for the job.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;One lesson I've learned while building automation solutions is this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The fastest flow isn't always the one with the most actions—it's the one with the fewest necessary actions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Next time you add an &lt;strong&gt;Apply to each&lt;/strong&gt;, pause for a moment and ask yourself:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can XPath solve this instead?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You might be surprised how much simpler your flow becomes.&lt;/p&gt;

&lt;p&gt;If you enjoy practical tips on Power Automate, SharePoint, Microsoft 365, SPFx, Python, and AI-powered automation, stay connected for more articles.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>powerplatform</category>
      <category>powerautomate</category>
      <category>powerfuldevs</category>
    </item>
  </channel>
</rss>
