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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Fill rows based on combined values from succeeding rows

Here's my current dataset:

 

Column 1Column 2
Customer Name1aaa
Street Name1bbb
City Name1ccc
Country1ddd
Customer Name2eee
Street Name2fff
City Name2ggg
Country2hhh

 

I want it to look like this:

 

Column 1Column 2
Customer Name1, Street Name1, City Name1, Country1  aaa
Customer Name1, Street Name1, City Name1, Country1bbb
Customer Name1, Street Name1, City Name1, Country1 ccc
Customer Name1, Street Name1, City Name1, Country1ddd
Customer Name2, Street Name2, City Name2, Country2eee
Customer Name2, Street Name2, City Name2, Country2fff
Customer Name2, Street Name2, City Name2, Country2ggg
Customer Name2, Street Name2, City Name2, Country2hhh

 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Does every customer have the same 4 rows? Here is one way, otherwise you need other approaches 

 

Vera_33_0-1627358922273.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xcw7DoAgEADRq5itafQK9DaWhILPAhZIgkvB7RVJiNq+SUYI4OWkFDFPq4o4AwOlFEgmYKOMSIO11g/znepAY0zHVA7KtZG1ttP7u9wBEf/fxs6577eh9/79bRRCACkv", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each Number.RoundTowardZero([Index]/4)),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Custom"}, {{"all", each Text.Combine( _[Column1],",") }}),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"Custom"}, #"Grouped Rows", {"Custom"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"all"}, {"all"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded Grouped Rows",{"all", "Column2"})
in
    #"Removed Other Columns"

 

View solution in original post

3 REPLIES 3
Syndicate_Admin
Administrator
Administrator

Hi @rblaze21 

 

Does every customer have the same 4 rows? Here is one way, otherwise you need other approaches 

 

Vera_33_0-1627358922273.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xcw7DoAgEADRq5itafQK9DaWhILPAhZIgkvB7RVJiNq+SUYI4OWkFDFPq4o4AwOlFEgmYKOMSIO11g/znepAY0zHVA7KtZG1ttP7u9wBEf/fxs6577eh9/79bRRCACkv", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each Number.RoundTowardZero([Index]/4)),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Custom"}, {{"all", each Text.Combine( _[Column1],",") }}),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"Custom"}, #"Grouped Rows", {"Custom"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"all"}, {"all"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded Grouped Rows",{"all", "Column2"})
in
    #"Removed Other Columns"

 

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Anonymous 

 

Does every customer have the same 4 rows? Here is one way, otherwise you need other approaches 

 

Vera_33_0-1627358922273.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Xcw7DoAgEADRq5itafQK9DaWhILPAhZIgkvB7RVJiNq+SUYI4OWkFDFPq4o4AwOlFEgmYKOMSIO11g/znepAY0zHVA7KtZG1ttP7u9wBEf/fxs6577eh9/79bRRCACkv", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each Number.RoundTowardZero([Index]/4)),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"Custom"}, {{"all", each Text.Combine( _[Column1],",") }}),
    #"Merged Queries" = Table.NestedJoin(#"Added Custom", {"Custom"}, #"Grouped Rows", {"Custom"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"all"}, {"all"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded Grouped Rows",{"all", "Column2"})
in
    #"Removed Other Columns"

 

Anonymous
Not applicable

Thank you so much!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors