Here's one approach.
I started with data in this Excel Table named Table1:
[TABLE="width: 128"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]Alpha[/TD]
[TD="align: right"]188[/TD]
[/TR]
[TR]
[TD]Alpha[/TD]
[TD="align: right"]272[/TD]
[/TR]
[TR]
[TD]Alpha[/TD]
[TD="align: right"]151[/TD]
[/TR]
[TR]
[TD]Alpha[/TD]
[TD="align: right"]268[/TD]
[/TR]
[TR]
[TD]Bravo[/TD]
[TD="align: right"]294[/TD]
[/TR]
[TR]
[TD]Bravo[/TD]
[TD="align: right"]108[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]246[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]163[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]260[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]203[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]110[/TD]
[/TR]
</tbody>[/TABLE]
I referenced that table in Power Query....these are the annotated steps in the query:
Code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"Name"}, {{"Group", each _, type table}}),
// Start creating a list of names to intersperse with the existing names
#"Removed Columns" = Table.RemoveColumns(#"Grouped Rows",{"Group"}),
// Add a column containing the original name with "_Blank" appended
#"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each [Name] & "_Blank"),
// Remove the original Name column
#"Removed Columns1" = Table.RemoveColumns(#"Added Custom",{"Name"}),
// Rename the new column to match the original data
#"Renamed Columns" = Table.RenameColumns(#"Removed Columns1",{{"Custom", "Name"}}),
/* Append the new names to the previous data
For this step I appended the "Renamed Columns" step to itself
then I edited the step in the formula bar to use the "Grouped Rows" step
*/
#"Appended Query" = Table.Combine({#"Grouped Rows", #"Renamed Columns"}),
// Sort the records to place each new name below its parent
#"Sorted Rows" = Table.Sort(#"Appended Query",{{"Name", Order.Ascending}}),
// Add an index to keep the grouped records in that order
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1),
// Remove the original "Name" column (it will be replaced in the next step)
#"Removed Columns2" = Table.RemoveColumns(#"Added Index",{"Name"}),
// Expand the new column
#"Expanded Group" = Table.ExpandTableColumn(#"Removed Columns2", "Group", {"Name", "Amount"}, {"Group.Name", "Group.Amount"})
in
#"Expanded Group"
If you load the results to a table...this is what you get:
[TABLE="width: 253"]
<tbody>[TR]
[TD]Group.Name[/TD]
[TD]Group.Amount[/TD]
[TD]Index[/TD]
[/TR]
[TR]
[TD]Alpha[/TD]
[TD="align: right"]188[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]Alpha[/TD]
[TD="align: right"]272[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]Alpha[/TD]
[TD="align: right"]151[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD]Alpha[/TD]
[TD="align: right"]268[/TD]
[TD="align: right"]0[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]Bravo[/TD]
[TD="align: right"]294[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]Bravo[/TD]
[TD="align: right"]108[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]246[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]163[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]260[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]203[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]Charlie[/TD]
[TD="align: right"]110[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="align: right"]5[/TD]
[/TR]
</tbody>[/TABLE]
Is that something you can work with?