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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors