let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCshMLSpKVdIBMgyBZFhiTmZKTKmBQaolkBfkGKwUq4OiyAhI+uXnKZShKPRNzCssTVXISVRISSxJRddjTIzBJngNTlUoyS9JzEHXZEqMyWYETM7JTC2F6EkszQHpSMQTEjAl+MMBm6F4QgGmhFAYwA31SkwGChUDJb1wuxVJEXGujQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Noms = _t, Dossiers = _t, Statuts = _t, Commentaires = _t]),
GroupByName = Table.Group(Source, {"Noms"}, {{"NB", each Table.RowCount(_), Int64.Type}, {"Data", each Table.RemoveColumns(_, {"Noms"}), type table}}),
TransformData =
let
fnTransformDataPerson = (dataPerson as table) as record =>
let
AddColumnIndex = Table.AddIndexColumn(dataPerson, "Index", 1, 1, Int64.Type),
UnpivotColumns = Table.UnpivotOtherColumns(AddColumnIndex, {"Index"}, "Attribut", "Value"),
AddColumnName = Table.AddColumn(UnpivotColumns, "Name", each [Attribut] & " " & Text.From([Index])),
ToRecord = Record.FromTable(AddColumnName)
in
ToRecord
in
Table.TransformColumns(GroupByName, {{"Data", fnTransformDataPerson, type record}}),
DevelopRecords =
let
listFields = Record.FieldNames(TransformData[Data]{List.PositionOf(TransformData[NB], List.Max(TransformData[NB]))})
in
Table.ExpandRecordColumn(TransformData, "Data", listFields, listFields),
RemoveColumnNB = Table.RemoveColumns(DevelopRecords,{"NB"})
in
RemoveColumnNB