<?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: How do I flatten columns into rows in Copy Data activity? in Pipelines</title>
    <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4034000#M4491</link>
    <description>&lt;P&gt;Have you tried using Dataflow Gen2 instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Or notebook)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have much experience with Azure Data Factory, but what I read some time back is that Dataflows Gen2 in Fabric is supposed to cover the role of Mapping Dataflows.&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2024 07:50:51 GMT</pubDate>
    <dc:creator>frithjof_v</dc:creator>
    <dc:date>2024-07-10T07:50:51Z</dc:date>
    <item>
      <title>How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4030912#M4464</link>
      <description>&lt;P&gt;I have a data pull that creates a new column for each row of data as follows:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is creating a column for each row, but what I need is for it to create a row for each numbered array. Essentially, I need to remove the data.results.#. and have a row for each numbered array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried changing the destination on the right from "data.results.0.amount" to "amount",&amp;nbsp;"data.results.1.amount" to "amount", etc. but then it throws an error saying that there are duplicate columns, so that's not the way to go. The closest thing I could find online was something about a "Flatten activity" and "unroll" which I don't see available in Microsoft Fabric.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any ideas on how to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2024 18:03:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4030912#M4464</guid>
      <dc:creator>DevinL</dc:creator>
      <dc:date>2024-07-08T18:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4031376#M4472</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="735290" data-lia-user-login="DevinL" class="lia-mention lia-mention-user"&gt;DevinL&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I don't think you should have duplicate naming in the first place, then you can follow the steps below.&lt;/P&gt;
&lt;P&gt;1. If you are using Azure Data Factory or Synapse Analytics, you can use Data Flow to perform the spreading. The "Spread" transformation allows you to expand an array into separate rows.&lt;/P&gt;
&lt;P&gt;2. Select the array to expand. This creates a new row for each element in the array. Or, if your array is nested within another array or object, you can choose to expand the root directory.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. After unfolding, map the fields from the original structure to the new unfolded structure.&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Of course, I searched for an official documentation you can read:&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/azure/data-factory/data-flow-flatten" target="_blank"&gt;Flatten transformation in mapping data flow - Azure Data Factory &amp;amp; Azure Synapse | Microsoft Learn&lt;/A&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;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Best Regards&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;Yilong Zhou&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 6.0pt;"&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2024 02:06:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4031376#M4472</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-09T02:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4032951#M4487</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;I have a data pull that creates a new column for each row of data as follows:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is creating a column for each row, but what I need is for it to create a row for each numbered array. Essentially, I need to remove the data.results.#. and have a row for each numbered array.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried changing the destination on the right from "data.results.0.amount" to "amount",&amp;nbsp;"data.results.1.amount" to "amount", etc. but then it throws an error saying that there are duplicate columns, so that's not the way to go. The closest thing I could find online was something about a "Flatten activity" and "unroll" which I don't see available in Microsoft Fabric.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any ideas on how to do this?&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 09 Jul 2024 16:33:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4032951#M4487</guid>
      <dc:creator>DevinL</dc:creator>
      <dc:date>2024-07-09T16:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4033578#M4488</link>
      <description>&lt;P&gt;Thanks for the reply, but this solution doesn't work in synapse Data Engineering.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 03:21:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4033578#M4488</guid>
      <dc:creator>DevinL</dc:creator>
      <dc:date>2024-07-10T03:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4034000#M4491</link>
      <description>&lt;P&gt;Have you tried using Dataflow Gen2 instead?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Or notebook)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have much experience with Azure Data Factory, but what I read some time back is that Dataflows Gen2 in Fabric is supposed to cover the role of Mapping Dataflows.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 07:50:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4034000#M4491</guid>
      <dc:creator>frithjof_v</dc:creator>
      <dc:date>2024-07-10T07:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035215#M4501</link>
      <description>&lt;P&gt;Yes, I've tried using dataflow gen2 but I can't seem to find a way to get these number array columns into rows. In Dataflow gen2 I can import the JSON file and it will expand all of the individual arrays. I don't see a way to put the data into rows instead of one row with many of columns.&lt;BR /&gt;&lt;BR /&gt;I tried to repost this into the Synapse forum, because I didn't mean to post in the Data Factory forum, but then a very "helpful" person merged the topics and stuck it back into the Data Factry forum. XD&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&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>Wed, 10 Jul 2024 16:45:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035215#M4501</guid>
      <dc:creator>DevinL</dc:creator>
      <dc:date>2024-07-10T16:45:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035299#M4503</link>
      <description>&lt;P&gt;Perhaps, under the Transform pane, you could utilize the Transpose or Pivot/Unpivot functions.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 17:39:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035299#M4503</guid>
      <dc:creator>frithjof_v</dc:creator>
      <dc:date>2024-07-10T17:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035339#M4504</link>
      <description>&lt;P&gt;I am curious why the data source is creating a data structure like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it a JSON data source?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems like instead of creating each record as a new json object (aka record), it creates a new duplicate of properties.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a limit of how many columns this data source will create? Will it continue to increase the number of columns as time goes?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I would try to transpose the columns into rows, you would then get 2 columns with many rows. The first column would contain the original column names, and the second column would contain the values.&lt;/P&gt;&lt;P&gt;(Before you do the transpose, you would need to use the "Use headers as first row" option).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I would try to split the content of the first column into three columns, so you will get three columns with this content:&lt;/P&gt;&lt;P&gt;-"data.results."&lt;/P&gt;&lt;P&gt;- the number&lt;/P&gt;&lt;P&gt;- the attribute name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And you will also still have the column which contains the value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I would remove the column which only contains the string "data.results" in each cell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would do a pivot on the column which contains the attribute names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that could work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;(this code contains some dummy data I entered, you can paste this entire code in Advanced editor and see what I mean).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;let
  Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlXSUTI0MACSxkBsDsSmII6hUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [data.results.0.account_id = _t, data.results.0.amount = _t, data.results.0.invoice_id = _t, data.results.1.account_id = _t, data.results.1.amount = _t, data.results.1.invoice_id = _t]),
  #"Changed column type" = Table.TransformColumnTypes(Source, {{"data.results.0.account_id", Int64.Type}, {"data.results.0.amount", Int64.Type}, {"data.results.0.invoice_id", Int64.Type}, {"data.results.1.account_id", Int64.Type}, {"data.results.1.amount", Int64.Type}, {"data.results.1.invoice_id", Int64.Type}}),
  #"Demoted headers" = Table.DemoteHeaders(#"Changed column type"),
  #"Transposed table" = Table.Transpose(#"Demoted headers"),
  #"Split column by delimiter" = Table.SplitColumn(Table.TransformColumnTypes(#"Transposed table", {{"Column1", type text}}), "Column1", Splitter.SplitTextByDelimiter("."), {"Column1.1", "Column1.2", "Column1.3", "Column1.4"}),
  #"Changed column type 1" = Table.TransformColumnTypes(#"Split column by delimiter", {{"Column1.1", type text}, {"Column1.2", type text}, {"Column1.3", Int64.Type}, {"Column1.4", type text}}),
  #"Removed columns" = Table.RemoveColumns(#"Changed column type 1", {"Column1.1", "Column1.2"}),
  #"Renamed columns" = Table.RenameColumns(#"Removed columns", {{"Column1.3", "RowID"}}),
  #"Pivoted column" = Table.Pivot(Table.TransformColumnTypes(#"Renamed columns", {{"Column1.4", type text}}), List.Distinct(Table.TransformColumnTypes(#"Renamed columns", {{"Column1.4", type text}})[Column1.4]), "Column1.4", "Column2"),
  #"Changed column type 2" = Table.TransformColumnTypes(#"Pivoted column", {{"RowID", Int64.Type}, {"account_id", Int64.Type}, {"amount", Int64.Type}, {"invoice_id", Int64.Type}})
in
  #"Changed column type 2"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 18:58:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035339#M4504</guid>
      <dc:creator>frithjof_v</dc:creator>
      <dc:date>2024-07-10T18:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035387#M4506</link>
      <description>&lt;P&gt;However, I see now that your source data seems to have a very high number of columns (aka attributes or properties): 1120. Will this number grow?&lt;/P&gt;&lt;P&gt;I'm not sure how well it will work in Dataflow gen2. (But I would give it a try). I'm not sure if there is a limit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps it is possible to manipulate the json file directly so that the json gets structured in a format which is easier to use. I think each data.result.x should be a separate object in the json. I think that is a usual way to structure a json. Then you would get each object as a new row inside the Dataflow Gen2 (or Data pipeline), and not many columns. (i.e. the "usual format").&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am thinking maybe it could be possible to do that manipulation of the json in a Notebook, by using Python code.&lt;/P&gt;&lt;P&gt;Or maybe the source system which produces the json could structure the json differently, so you won't get this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Or perhaps that manipulation of the json file is even possible to do in a data pipeline or dataflow gen2, but I don't know how and haven't seen something like that.)&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 19:04:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035387#M4506</guid>
      <dc:creator>frithjof_v</dc:creator>
      <dc:date>2024-07-10T19:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035550#M4507</link>
      <description>&lt;P&gt;Thanks for the responses!&lt;BR /&gt;&lt;BR /&gt;The data shouldn't have that many rows normally because the process would run daily and probably have less than 20 entries in a day.&amp;nbsp; That being said, I'm not sure I could make this work if there were over 90 entries because it stops creating columns at a certain point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There was an option in the transform pane to "Extract" text before/after a delimiter and you can also set it to ignore x number of delimiters.&amp;nbsp; I did an extract with a delimiter of "." and ignored the first two and was left with the column names I needed.&lt;BR /&gt;&lt;BR /&gt;The trouble now is transposing/pivoting to get the correct results in the correct columns.&lt;BR /&gt;&lt;BR /&gt;It's getting a lot closer!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 20:50:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035550#M4507</guid>
      <dc:creator>DevinL</dc:creator>
      <dc:date>2024-07-10T20:50:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035565#M4508</link>
      <description>&lt;P&gt;That did it.&lt;/P&gt;&lt;P&gt;The example code you gave was a perfect example!&lt;BR /&gt;&lt;BR /&gt;I'm going to take this and find a way to make this work for any sized table. Not sure how, but that is what's next.&lt;BR /&gt;&lt;BR /&gt;The hope is that when the API pulls the data and writes it to a JSON file in the datalake that this dataflow gen2 can take that JSON (no matter how many rows) and do the same conversion the put it into a datalake table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all your help!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 21:02:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4035565#M4508</guid>
      <dc:creator>DevinL</dc:creator>
      <dc:date>2024-07-10T21:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I flatten columns into rows in Copy Data activity?</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4629782#M7360</link>
      <description>&lt;P&gt;I found a workaround for this, which doesn't involve Dataflow Gen2. You can unlock a hidden Mapping interface. I've described in detail the approach here :&amp;nbsp;&lt;A href="https://www.mattiasdesmet.be/2025/03/28/fabric-hidden-collection-reference-in-copy-activity/" target="_blank"&gt;Fabric : Hidden Collection Reference in Copy Activity - Mattias De Smet&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope it helps!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Mar 2025 18:14:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-do-I-flatten-columns-into-rows-in-Copy-Data-activity/m-p/4629782#M7360</guid>
      <dc:creator>mattiasdesmet</dc:creator>
      <dc:date>2025-03-28T18:14:23Z</dc:date>
    </item>
  </channel>
</rss>

