So I have a table of widgets and the layers of material needed to make them:
I need to transpose these values into something like this:
I already have an awkward function to do this, but it requires manually adjusting the size of each HSTACK element to generate (roughly) equal columns (FirstGroup, SecondGroup, and ThirdGroup are the manually-determined lengths of each column):
I know there's an automated way to do this but I'm just not finding it. Can anyone help?
(I'd also rather have a dynamic VSTACK(TRANSPOSE(...)) option instead of making entries for each row of the table, but that's secondary.)
It doesn't have to be an array formula - the whole sheet will be generated with VBA so a code option is fine too.
Type | Layer 1 | Layer 2 | Layer 3 | Layer 4 | Layer 5 | Layer 6 | Layer 7 |
Type1 | 1.a | ||||||
Type2 | 2.a | ||||||
Type3 | 3.a | 3.b | |||||
Type4 | 4.a | 4.b | 4.c | 4.d | 4.e | ||
Type5 | 5.a | 5.b | 5.c | 5.d | |||
Type6 | 6.a | 6.b | 6.c |
I need to transpose these values into something like this:
Type1 | Type4 | Type5 | ||
1.a | 4.a | 5.a | ||
4.b | 5.b | |||
Type2 | 4.c | 5.c | ||
2.a | 4.d | 5.d | ||
4.e | ||||
Type3 | Type6 | |||
3.a | 6.a | |||
3.b | 6.b | |||
6.c |
I already have an awkward function to do this, but it requires manually adjusting the size of each HSTACK element to generate (roughly) equal columns (FirstGroup, SecondGroup, and ThirdGroup are the manually-determined lengths of each column):
Excel Formula:
=LET(bigarray,
VSTACK(
LET(CurrEntry,1,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0)),"",
LET(CurrEntry,2,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0)),"",
LET(CurrEntry,3,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0)),"",
LET(CurrEntry,4,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0)),"",
LET(CurrEntry,5,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0)),"",
LET(CurrEntry,6,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0)),"",
LET(CurrEntry,7,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0)),"",
LET(CurrEntry,8,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0)),"",
LET(CurrEntry,9,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0)),"",
LET(CurrEntry,10,CurrFilt,IFERROR(CHOOSECOLS(TRANSPOSE(tbl_Sample),CurrEntry),""),FILTER(CurrFilt,CurrFilt<>0))
),
IFERROR(
LET(FirstGroup,9,
SecondGroup,7,
ThirdGroup,10,
HSTACK(
CHOOSEROWS(bigarray,SEQUENCE(FirstGroup)),"",
CHOOSEROWS(bigarray,SEQUENCE(SecondGroup,,FirstGroup+2)),"",
CHOOSEROWS(bigarray,SEQUENCE(ThirdGroup,,FirstGroup+SecondGroup+2))
)
)
,"")
)
I know there's an automated way to do this but I'm just not finding it. Can anyone help?
(I'd also rather have a dynamic VSTACK(TRANSPOSE(...)) option instead of making entries for each row of the table, but that's secondary.)
It doesn't have to be an array formula - the whole sheet will be generated with VBA so a code option is fine too.