<?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: Combine multiple rows into one row in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-multiple-rows-into-one-row/m-p/3306754#M123513</link>
    <description>&lt;P&gt;In Power Query I pasted your data into a table and achieved that result with this M code.&lt;BR /&gt;The first thing it does is transposes the table so your headers are now rows in column1. Then I replaced all the " " values with nulls and created a custom column to get the first non-null value (the ?? in the code below means to coalesce) This gets the first value from each of those columns and returns it as 1 column which I named Value.&lt;BR /&gt;Then I removed columns 2-5 and pivoted the header column (column1) with 'Value' as the values using the "Don't aggregate" under advanced options of the pivot column dialog box.&lt;BR /&gt;&lt;BR /&gt;Hope this helps!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kvMTVXSUfJ0MQSRJam5CiGVBRARIzBpDCRDg10UHHPzS/NKwEImQDIoMS8bSDnn55UUJSaXFAPZfvklqcVKsTrRSk5ASZB5ClBsYWlogMRFxdg0wLChAUhfsIe5BcgxJgYGWHUZGoEcGZaal5JfhNMafFaZmJphVx8LAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t, #"(blank).5" = _t, #"(blank).6" = _t, #"(blank).7" = _t, #"(blank).8" = _t, #"(blank).9" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}, {"(blank).5", type text}, {"(blank).6", type text}, {"(blank).7", type text}, {"(blank).8", type text}, {"(blank).9", type text}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Replaced Value" = Table.ReplaceValue(#"Transposed Table"," ",null,Replacer.ReplaceValue,{"Column2", "Column3", "Column4", "Column5"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value", "Value", each [Column2] ?? [Column2] ?? [Column3] ?? [Column4] ??[Column5]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column2", "Column3", "Column4", "Column5"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Column1]), "Column1", "Value")
in
    #"Pivoted Column"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2023 18:26:33 GMT</pubDate>
    <dc:creator>Syk</dc:creator>
    <dc:date>2023-06-28T18:26:33Z</dc:date>
    <item>
      <title>Combine multiple rows into one row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-multiple-rows-into-one-row/m-p/3306585#M123502</link>
      <description>&lt;P&gt;I have the following table&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;ID1&lt;/TD&gt;&lt;TD&gt;Item Type&lt;/TD&gt;&lt;TD&gt;ID2&lt;/TD&gt;&lt;TD&gt;ID3&lt;/TD&gt;&lt;TD&gt;USD Amount&lt;/TD&gt;&lt;TD&gt;ID4&lt;/TD&gt;&lt;TD&gt;Rank&lt;/TD&gt;&lt;TD&gt;Contracts&lt;/TD&gt;&lt;TD&gt;Notes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bank1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;8910&lt;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;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Utilizing DAX or Power Query, I need it to be transformed to the following&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;ID1&lt;/TD&gt;&lt;TD&gt;Item Type&lt;/TD&gt;&lt;TD&gt;ID2&lt;/TD&gt;&lt;TD&gt;ID3&lt;/TD&gt;&lt;TD&gt;USD Amount&lt;/TD&gt;&lt;TD&gt;ID4&lt;/TD&gt;&lt;TD&gt;Rank&lt;/TD&gt;&lt;TD&gt;Contracts&lt;/TD&gt;&lt;TD&gt;Notes&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bank1&lt;/TD&gt;&lt;TD&gt;123&lt;/TD&gt;&lt;TD&gt;Vendor&lt;/TD&gt;&lt;TD&gt;8910&lt;/TD&gt;&lt;TD&gt;456&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;SH782&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I utilized the SUMMARIZE function and pulled all of those datafields into it, but still get the rows being separated.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 15:44:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-multiple-rows-into-one-row/m-p/3306585#M123502</guid>
      <dc:creator>botaac</dc:creator>
      <dc:date>2023-06-28T15:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Combine multiple rows into one row</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-multiple-rows-into-one-row/m-p/3306754#M123513</link>
      <description>&lt;P&gt;In Power Query I pasted your data into a table and achieved that result with this M code.&lt;BR /&gt;The first thing it does is transposes the table so your headers are now rows in column1. Then I replaced all the " " values with nulls and created a custom column to get the first non-null value (the ?? in the code below means to coalesce) This gets the first value from each of those columns and returns it as 1 column which I named Value.&lt;BR /&gt;Then I removed columns 2-5 and pivoted the header column (column1) with 'Value' as the values using the "Don't aggregate" under advanced options of the pivot column dialog box.&lt;BR /&gt;&lt;BR /&gt;Hope this helps!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kvMTVXSUfJ0MQSRJam5CiGVBRARIzBpDCRDg10UHHPzS/NKwEImQDIoMS8bSDnn55UUJSaXFAPZfvklqcVKsTrRSk5ASZB5ClBsYWlogMRFxdg0wLChAUhfsIe5BcgxJgYGWHUZGoEcGZaal5JfhNMafFaZmJphVx8LAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t, #"(blank).5" = _t, #"(blank).6" = _t, #"(blank).7" = _t, #"(blank).8" = _t, #"(blank).9" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}, {"(blank).5", type text}, {"(blank).6", type text}, {"(blank).7", type text}, {"(blank).8", type text}, {"(blank).9", type text}}),
    #"Transposed Table" = Table.Transpose(#"Changed Type"),
    #"Replaced Value" = Table.ReplaceValue(#"Transposed Table"," ",null,Replacer.ReplaceValue,{"Column2", "Column3", "Column4", "Column5"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value", "Value", each [Column2] ?? [Column2] ?? [Column3] ?? [Column4] ??[Column5]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column2", "Column3", "Column4", "Column5"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Column1]), "Column1", "Value")
in
    #"Pivoted Column"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 18:26:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Combine-multiple-rows-into-one-row/m-p/3306754#M123513</guid>
      <dc:creator>Syk</dc:creator>
      <dc:date>2023-06-28T18:26:33Z</dc:date>
    </item>
  </channel>
</rss>

