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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Top Kudoed Authors