let
// calculates max number of items in the list of lists
max_count = (lst) => List.Max(List.Transform(lst, (x) => List.Count(x))),
// splits list column and creates custom column names
exp_column = (tbl, column_name) => Table.SplitColumn(
tbl,
column_name,
(x) => x,
List.Transform(
{1..max_count(Table.Column(tbl, column_name))},
(x) => column_name & " " & Text.From(x)
)
),
// your source table
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
// just group by id and collect names and events into distinct lists
group = Table.Buffer(
Table.Group(
Source,
"Order ID",
{
{"Name", (x) => List.Distinct(x[Names])},
{"Event", (x) => List.Distinct(x[Event])}
}
)
),
// apply our functions to finish this job
exp_names = exp_column(group, "Name"),
exp_events = exp_column(exp_names, "Event")
in
exp_events