Forum Discussion
GibbE155
Jul 18, 2020Copper Contributor
Reorganised a long format table to a wide data table
Hi, I'm struggling to reorganise a data table from long format to a wide format. my data is organised as follows: Value Sample 3456434 1 56645677 1 46356 1 24556 2 235478 2...
SergeiBaklan
Jul 18, 2020MVP
If with formulas
that could be
=$C$2 & " " & TRANSPOSE(UNIQUE(C3:C7))
for headers and
=FILTER($B$3:$B$7,$C$3:$C$7=INDEX(UNIQUE($C$3:$C$7),COLUMN()-COLUMN($E$2)+1))
for the column.
If use named range same formulas could be
=INDEX(Range,1,2) & " " & TRANSPOSE(UNIQUE(INDEX(Range,2,2):INDEX(Range,ROWS(Range),2)))
and
=FILTER(INDEX(Range,2,1):INDEX(Range,ROWS(Range),1),
INDEX(Range,2,2):INDEX(Range,ROWS(Range),2)=
INDEX(UNIQUE(INDEX(Range,2,2):INDEX(Range,ROWS(Range),2)),COLUMN()-COLUMN($H$2)+1)
)
Formulas could be generated for pre-DA Excel as well.
If with Power Query another variant could be
let
Source = Excel.CurrentWorkbook(){[Name="Range"]}[Content],
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Grouped Rows" = Table.Group(#"Promoted Headers", {"Sample"}, {{"Count", each _[Value ]}}),
Custom1 = Table.FromColumns(#"Grouped Rows"[Count],
List.Transform(#"Grouped Rows"[Sample], each "Sample " & Text.From(_)))
in
Custom1