let
tbl = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Source = Table.RenameColumns(tbl, {"Relationship Code", "Relationship"}),
tcn = Table.ColumnNames(Source),
headers = List.Range(tcn, 1, 5),
rel = {"", "SPOUSE ", "DEP1. ", "DEP2. ", "DEP3. "},
commoncols = List.Range(tcn, 6,5) & List.LastN(tcn,2),
lstheaders = List.Accumulate(rel, {}, (s,c)=> s & {{"SSN"} & List.Transform(headers, each c & _) & commoncols}),
lsttables = List.Transform(lstheaders, each Table.SelectColumns(Source, _)),
tcn1 = Table.ColumnNames(lsttables{0}),
lsttables1 = List.Transform(lsttables, each Table.RenameColumns(_, List.Zip({Table.ColumnNames(_), tcn1}))),
listtables2 = List.Zip({lsttables1, {1..List.Count(lsttables1)}}),
listtables3 = List.Transform(listtables2, each Table.AddColumn(_{0}, "Order", (x)=> _{1})),
tbl1 = Table.Combine(listtables3),
tbl2 = Table.SelectRows(tbl1, each ([Last Name] <> null)),
tbl3 = Table.Sort(tbl2,{{"SSN", Order.Ascending}, {"Order", Order.Ascending}}),
Result = Table.RenameColumns(Table.RemoveColumns(tbl3,{"Order"}),{"Relationship", "Relationship Code"})
in
Result