<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Operation on target ForEach1 failed: The function 'length' expects its parameter to be an array in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4750326#M10550</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1283468"&gt;@v-agajavelly&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/913195"&gt;@nilendraFabric&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/10288"&gt;@BhaveshPatel&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for all your suggestions. All point to the same approach.&lt;BR /&gt;&lt;BR /&gt;I solved the issue as follows.&lt;BR /&gt;&lt;BR /&gt;In the Query area of the Lookup settings, I first used&lt;BR /&gt;&lt;BR /&gt;select TABLE_SCHEMA as SchemaName , TABLE_NAME as TableName&lt;BR /&gt;From ecommerce INFORMATION_SCHEMA_TABLES&lt;BR /&gt;where TABLE_TYPE= 'BASIC TABLE'&lt;BR /&gt;&lt;BR /&gt;This did give me thee schemaname and tablename. But did not have the option to select value array in the For Each Loop.&lt;BR /&gt;&lt;BR /&gt;I changed the query to&lt;BR /&gt;&lt;BR /&gt;select s.name as SchemaName,&lt;BR /&gt;t.name as TableName from sys.tables t&lt;BR /&gt;JOIN sys.schemas s on t.schema_Id = s.schema_Id Order by s.name ,t.name&lt;BR /&gt;&lt;BR /&gt;This also gave me the SchemaName and TableName. And it allowed me to choose Lookuparray in the ForEach loop.&lt;BR /&gt;&lt;BR /&gt;So by the above in the query solved my issue in the ForEach loop.&lt;BR /&gt;&lt;BR /&gt;Another thing I observed is&lt;BR /&gt;&lt;BR /&gt;In the destination screen of the Copy acitity&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CheenuSing_0-1751426684498.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1280423i24A37455C86044E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CheenuSing_0-1751426684498.png" alt="CheenuSing_0-1751426684498.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I put the&amp;nbsp;@item().TableName in the fileName above, it did generate the files but coluld not be previewed in the Lakehouse. And the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CheenuSing_1-1751426783828.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1280425iA2D564E5FA1F8941/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CheenuSing_1-1751426783828.png" alt="CheenuSing_1-1751426783828.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;whas greyed out .txt and could not be changed to csv.&lt;BR /&gt;With the above settings the files got created with .csv extension and could be previewed.&lt;BR /&gt;However the file names included dbo. in the beginning of the file name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1283468"&gt;@v-agajavelly&lt;/a&gt;&amp;nbsp;. May be you can check with internal documentation for above behaviour.&lt;BR /&gt;&lt;BR /&gt;With this I have solved my issue.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;CheenuSing&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jul 2025 03:30:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2025-07-02T03:30:50Z</dc:date>
    <item>
      <title>Operation on target ForEach1 failed: The function 'length' expects its parameter to be an array</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4748492#M10502</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I am using Fabric trial licence.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I created a pipeline with Lookup as startting point to retrieve SchemaName and TableName from on prem sql database.&lt;BR /&gt;It wotks fine and gives me the desired output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CheenuSing_0-1751285874441.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1280011iBA53BD2AF8416A9B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CheenuSing_0-1751285874441.png" alt="CheenuSing_0-1751285874441.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then I created a For Each activiy to copy data from each table to a landing areas in the lakehouse&lt;/P&gt;&lt;P&gt;settings for ForEach&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CheenuSing_1-1751285996772.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1280013i90949ABF8FD5102E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CheenuSing_1-1751285996772.png" alt="CheenuSing_1-1751285996772.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then I set up the copy activity within for each&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CheenuSing_2-1751286180795.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1280014iC9E4E84F22365277/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CheenuSing_2-1751286180795.png" alt="CheenuSing_2-1751286180795.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I get the error&amp;nbsp;&lt;BR /&gt;Operation on target ForEach1 failed: The function 'length' expects its parameter to be an array or a string. The provided value is of type 'Object' .&lt;BR /&gt;&lt;BR /&gt;If I change the setting for For Each to&amp;nbsp;@activity('Lookup1).output.firstRow&lt;/P&gt;&lt;P&gt;still get the same error.&lt;BR /&gt;How to fix this error ?&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;CheenuSing&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2025 12:28:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4748492#M10502</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-06-30T12:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: Operation on target ForEach1 failed: The function 'length' expects its parameter to be an array</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4748780#M10509</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try&amp;nbsp;Modify the ForEach `Items` property to reference the full array from the Lookup output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@activity('Lookup1').output.value&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jun 2025 16:54:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4748780#M10509</guid>
      <dc:creator>nilendraFabric</dc:creator>
      <dc:date>2025-06-30T16:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Operation on target ForEach1 failed: The function 'length' expects its parameter to be an array</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4749066#M10515</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/913195"&gt;@nilendraFabric&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHen I tried your suggestion I get the following error&lt;BR /&gt;&lt;BR /&gt;The expression 'length(activity('Lookup1').output.value)' cannot be evaluated because property 'value' doesn't exist, available properties are 'firstRow, effectiveIntegrationRuntime, billingReference, durationInQueue'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also why Lookup1 value array option is not shown under&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CheenuSing_0-1751340124813.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1280144i630F14B903979477/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CheenuSing_0-1751340124813.png" alt="CheenuSing_0-1751340124813.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Why is it so ?&lt;BR /&gt;&lt;BR /&gt;Any help will be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;BR /&gt;CheenuSing&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 03:23:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4749066#M10515</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-07-01T03:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Operation on target ForEach1 failed: The function 'length' expects its parameter to be an array</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4749326#M10523</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Great question, I totally understand how this can be a bit confusing at first. The reason you're getting the error, the function 'length' expects its parameter to be an array... but got an object instead is because your Lookup activity is only returning a single row, not an array of rows and ForEach needs an array to loop over.&lt;/P&gt;
&lt;P&gt;In your Lookup activity settings, there’s a checkbox called “First row only” &amp;nbsp;this is currently enabled in your case (which is why your output shows .firstRow but not .value).&lt;/P&gt;
&lt;P&gt;When that’s turned ON, Lookup will return a single row as an object, not an array. That’s why @activity('Lookup1').output.value doesn’t exist and throws an error.&lt;/P&gt;
&lt;P&gt;Here’s what you can do to get it working:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Go to your Lookup activity&lt;/LI&gt;
&lt;LI&gt;In the Settings tab, uncheck the box for “First row only”&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;This will return the full list of rows as an array in the .value property&lt;/LI&gt;
&lt;/UL&gt;
&lt;LI&gt;Now, go to your ForEach activity&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;For the Items field, use this expression.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/OL&gt;
&lt;PRE&gt;@activity('Lookup1').output.value&lt;/PRE&gt;
&lt;P&gt;By adding .value i think, this will allow the ForEach loop to process each row returned by the Lookup (e.g., each SchemaName and TableName) one by one.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;If this response helps, consider marking it as &lt;STRONG&gt;“Accept as solution”&lt;/STRONG&gt; and giving a &lt;STRONG&gt;“kudos”&lt;/STRONG&gt; to assist other community members.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Akhil.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;SPAN data-teams="true"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 06:47:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4749326#M10523</guid>
      <dc:creator>v-agajavelly</dc:creator>
      <dc:date>2025-07-01T06:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Operation on target ForEach1 failed: The function 'length' expects its parameter to be an array</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4749461#M10529</link>
      <description>&lt;P&gt;For better output, You should try using Dataflow Gen 2. Self Service with lot more options. ( Filter the rows &amp;amp; each different tables)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BhaveshPatel_0-1751359812074.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1280230i5CF05D22B85C64BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BhaveshPatel_0-1751359812074.png" alt="BhaveshPatel_0-1751359812074.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try step by step process to get the desired outcomes. Both Fabric Data Factory and Dataflow Gen 2 is doing the same approach of data engineering.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 08:55:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4749461#M10529</guid>
      <dc:creator>BhaveshPatel</dc:creator>
      <dc:date>2025-07-01T08:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Operation on target ForEach1 failed: The function 'length' expects its parameter to be an array</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4750326#M10550</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1283468"&gt;@v-agajavelly&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/913195"&gt;@nilendraFabric&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/10288"&gt;@BhaveshPatel&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for all your suggestions. All point to the same approach.&lt;BR /&gt;&lt;BR /&gt;I solved the issue as follows.&lt;BR /&gt;&lt;BR /&gt;In the Query area of the Lookup settings, I first used&lt;BR /&gt;&lt;BR /&gt;select TABLE_SCHEMA as SchemaName , TABLE_NAME as TableName&lt;BR /&gt;From ecommerce INFORMATION_SCHEMA_TABLES&lt;BR /&gt;where TABLE_TYPE= 'BASIC TABLE'&lt;BR /&gt;&lt;BR /&gt;This did give me thee schemaname and tablename. But did not have the option to select value array in the For Each Loop.&lt;BR /&gt;&lt;BR /&gt;I changed the query to&lt;BR /&gt;&lt;BR /&gt;select s.name as SchemaName,&lt;BR /&gt;t.name as TableName from sys.tables t&lt;BR /&gt;JOIN sys.schemas s on t.schema_Id = s.schema_Id Order by s.name ,t.name&lt;BR /&gt;&lt;BR /&gt;This also gave me the SchemaName and TableName. And it allowed me to choose Lookuparray in the ForEach loop.&lt;BR /&gt;&lt;BR /&gt;So by the above in the query solved my issue in the ForEach loop.&lt;BR /&gt;&lt;BR /&gt;Another thing I observed is&lt;BR /&gt;&lt;BR /&gt;In the destination screen of the Copy acitity&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CheenuSing_0-1751426684498.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1280423i24A37455C86044E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CheenuSing_0-1751426684498.png" alt="CheenuSing_0-1751426684498.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If I put the&amp;nbsp;@item().TableName in the fileName above, it did generate the files but coluld not be previewed in the Lakehouse. And the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CheenuSing_1-1751426783828.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1280425iA2D564E5FA1F8941/image-size/medium?v=v2&amp;amp;px=400" role="button" title="CheenuSing_1-1751426783828.png" alt="CheenuSing_1-1751426783828.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;whas greyed out .txt and could not be changed to csv.&lt;BR /&gt;With the above settings the files got created with .csv extension and could be previewed.&lt;BR /&gt;However the file names included dbo. in the beginning of the file name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/1283468"&gt;@v-agajavelly&lt;/a&gt;&amp;nbsp;. May be you can check with internal documentation for above behaviour.&lt;BR /&gt;&lt;BR /&gt;With this I have solved my issue.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;BR /&gt;&lt;BR /&gt;CheenuSing&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jul 2025 03:30:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Operation-on-target-ForEach1-failed-The-function-length-expects/m-p/4750326#M10550</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-07-02T03:30:50Z</dc:date>
    </item>
  </channel>
</rss>

