Hi @Roberto,
Thanks for posting your question.
You can copy the full M script here, into a new blank query.
let
MaxOwnerCount = List.Max( List.Buffer( GroupRows[RowCount] )),
NewColumns = List.Transform( {1..MaxOwnerCount}, each "Owner " & Text.From(_) ),
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUYoA4kggNjYxAJJZKfmpDpl5yXrJ+blKsTrYlKQl5SQmZxNQlJWSmIdqkBNQNByqztDIGLtBmIowDXIGikYBcSBIjQEWy2IB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Org = _t, Repo = _t, Type = _t, Findings = _t, owner = _t]),
ChType = Table.TransformColumnTypes(Source,{{"Org", type text}, {"Repo", type text}, {"Type", type text}, {"Findings", Int64.Type}, {"owner", type text}}),
GroupRows = Table.Group(ChType, {"Org", "Repo", "Type", "Findings"}, {{"RowCount", each Table.RowCount(_), Int64.Type}, {"AllRows", each _, type table [Org=nullable text, Repo=nullable text, Type=nullable text, Findings=nullable number, owner=nullable text]}}),
AddOwner = Table.AddColumn(GroupRows, "Owner", each Text.Combine( [AllRows][owner], "|" )),
SplitColumn = Table.SplitColumn(AddOwner, "Owner", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), NewColumns ),
CleanUpColumns = Table.RemoveColumns(SplitColumn,{"AllRows", "RowCount"})
in
CleanUpColumns
.
For your requirement you can use the Group By option.
and extract the Owners from that nested table before splitting that into separate columns.
To dynamically create the required number of columns I’ve added 2 steps, before the Source step in this query, this way you can avoid hard coding new column names.
with this result.
.
I hope this is helpful.