Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
vidyasagar159
Helper II
Helper II

concatenate the last column records to first column record

Hello All,

 

Need some help with my below-reporting view format. 

 

Data:

NamecolorCategory
AppleRedFruit
ApplegreenFruit
GrapewhiteFruit
GrapeblackFruit
Onionwhiteveggi
OnionRedveggi
PepperRedVeggi
Peppergreenveggi

 

Expected 
  
Namecolor
Fruit 
AppleRed
Applegreen
Grapewhite
Grapeblack
veggi 
Onionwhite
OnionRed
PepperRed
Peppergreen
1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

@vidyasagar159 ,

Try this mcode:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kvMTVXSUUrOz8kvAtLOiSWp6flFlUqxOtFKjgUFOSDJoNQUIOlWVJpZgiKeXpSamoci416UWACSKc/ILEnFKpOUk5icjSLjn5eZn4ekpyw1PT0TRQZiP0I8ILWgILUILhGGKQFzGVRPLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Name", type text}, {"color", type text}, {"Category", type text}}),
    #"Capitalized Each Word" = Table.TransformColumns(#"Changed Type1",{{"Category", Text.Proper, type text}}),
    #"Grouped Rows" = Table.Group(#"Capitalized Each Word", {"Category"}, {{"Rows", each let _category = Table.FromList(List.Distinct(_[Category]), Splitter.SplitByNothing(), {"Name"}) in Table.Combine({_category, _}), type table}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"Rows"}),
    #"Expanded Rows" = Table.ExpandTableColumn(#"Removed Other Columns", "Rows", {"Name", "color"}, {"Name", "color"})
in
    #"Expanded Rows"

Capture.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

3 REPLIES 3
camargos88
Community Champion
Community Champion

@vidyasagar159 ,

 

I had to code on Advanced Editor.



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



vidyasagar159
Helper II
Helper II

@camargos88 

Great response!!!. For the below-grouped rows did you manually wrote the script in the editor? 

= Table.Group(#"Capitalized Each Word", {"Category"}, {{"Rows", each let _category = Table.FromList(List.Distinct(_[Category]), Splitter.SplitByNothing(), {"Name"}) in Table.Combine({_category, _}), type table}})

camargos88
Community Champion
Community Champion

@vidyasagar159 ,

Try this mcode:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kvMTVXSUUrOz8kvAtLOiSWp6flFlUqxOtFKjgUFOSDJoNQUIOlWVJpZgiKeXpSamoci416UWACSKc/ILEnFKpOUk5icjSLjn5eZn4ekpyw1PT0TRQZiP0I8ILWgILUILhGGKQFzGVRPLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Name", type text}, {"color", type text}, {"Category", type text}}),
    #"Capitalized Each Word" = Table.TransformColumns(#"Changed Type1",{{"Category", Text.Proper, type text}}),
    #"Grouped Rows" = Table.Group(#"Capitalized Each Word", {"Category"}, {{"Rows", each let _category = Table.FromList(List.Distinct(_[Category]), Splitter.SplitByNothing(), {"Name"}) in Table.Combine({_category, _}), type table}}),
    #"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"Rows"}),
    #"Expanded Rows" = Table.ExpandTableColumn(#"Removed Other Columns", "Rows", {"Name", "color"}, {"Name", "color"})
in
    #"Expanded Rows"

Capture.PNG



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.