I would like to transpose these two columns by keeping the unique values in C as header items and items in D grouped under the header groups
The header groups are transposed repeatedly instead of appearing only once.
Try the following formula, assuming there is no Excel Constraints
as per the tags posted & if i have understood correctly the required output, then the given formula should work:
• Formula used in cell F1
=LET(
a, C2:D42,
b, TAKE(a,,1),
c, DROP(a,,1),
ub, UNIQUE(b),
DROP(IFERROR(REDUCE("",TOROW(ub),LAMBDA(x,y,
HSTACK(x,VSTACK(y,FILTER(c,b=y))))),""),,1))
Update :
OP mentions in comment :
hey, tried it, but i get formula contains error.
Not sure what error you are getting, but there is one more neater and cleaner approach, and easy as well using POWER QUERY
To perform the task using POWER QUERY, follow the steps:
Table1
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Grouped Rows" = Table.Group(Source, {"Orgname"}, {{"All", each _, type table [Orgname=text, Fullname=text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([All],"Index",1,1)),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Orgname", "Fullname", "Index"}, {"Orgname", "Fullname", "Index"}),
#"Pivoted Column" = Table.Pivot(#"Expanded Custom", List.Distinct(#"Expanded Custom"[Orgname]), "Orgname", "Fullname"),
#"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
in
#"Removed Columns"
Update as per Screenshot from OP, looks they are using Older Version, then one could try the following:
• Formula used in cell D1
=IFERROR(INDEX($A$2:$A$42,MATCH(0,INDEX(COUNTIF($C$1:C1,$A$2:$A$42),,),0)),"")
The above formula needs to fill across. Also while exiting the edit mode, you would need to hit CTRL+SHIFT+ENTER, as these are array formulas.
• Formula used in cell D2
=IFERROR(INDEX($B$2:$B$42,AGGREGATE(15,6,
(ROW($B$2:$B$42)-ROW($B$2)+1)/(D$1=$A$2:$A$42),ROWS(D$1:D1))),"")
The above formula needs to fill down and fill right! Also while exiting the edit mode, you would need to hit CTRL+SHIFT+ENTER, as these are array formulas.
Excel can be downloaded from here