Forum Discussion
Elad_Magazanik
Nov 19, 2023Copper Contributor
Table transformation
Hi, does anyone have any idea on how to transform this table:
To this table:
Many thanks,
Elad
10 Replies
Sort By
- abdelazizallamCopper Contributor
- LorenzoSilver Contributor
With Get & Transform aka Power Query in attached file. Done with the UI/Menus only
Alternative:
let Source = Excel.CurrentWorkbook(){[Name="Table"]}[Content], RemovedBlankLocation = Table.SelectRows(Source, each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null})) ), FilledDownItem = Table.FillDown(RemovedBlankLocation, {"Item Number"}), TranposedLocations = Table.Group(FilledDownItem, {"Item Number"}, { {"LOCATIONS", each Table.Transpose(Table.SelectColumns(_, "Location")), type table}, {"LOC_COUNT", Table.RowCount, Int64.Type} } ), ColumnsToExpand = List.Transform({1..List.Max(TranposedLocations[LOC_COUNT])}, each "Column" & Text.From(_) ), RemovedLocCount = Table.RemoveColumns(TranposedLocations, {"LOC_COUNT"}), ExpandedLocations = Table.ExpandTableColumn(RemovedLocCount, "LOCATIONS", ColumnsToExpand, List.ReplaceValue(ColumnsToExpand, "Column", "Location ", Replacer.ReplaceText) ) in ExpandedLocations
- Elad_MagazanikCopper ContributorThank you for the assistance.
- LorenzoSilver Contributor
You're welcome Elad_Magazanik
(Don't undertand why you marked as solution the post from peiyezhu that refers to another Data transformation using Power Query IMHO)
- PeterBartholomew1Silver Contributor
This uses basic dynamic array formulas to generate a table of indices
= LET( n, ROWS(Table), k, SEQUENCE(n), k₀, FILTER(k, Table[Item Number]<>""), k₁, VSTACK(DROP(k₀, 1) - 1, n), idx, k₀ + {0,1,2,3,4}, items, INDEX(Table[Item Number], k₀), pivot, IF(idx<=k₁, INDEX(Table[Location], idx), ""), HSTACK(items, pivot) )
- OliverScheurichGold Contributor
=LET(filldown,
SCAN("",A2:A15,LAMBDA(ini,arr,IF(ISTEXT(arr),arr,ini))),
HSTACK(
UNIQUE(filldown),
IFNA(DROP(REDUCE("",SEQUENCE(ROWS(UNIQUE(filldown))),LAMBDA(x,y,VSTACK(x,TOROW(FILTER(B2:B15,filldown=INDEX(UNIQUE(filldown),y)))))),1),"")
)
)
With Office 365 or Excel for the web you can apply this formula.
- Elad_MagazanikCopper ContributorThank you! This is amazing!