UNPIVOTHEADERS function replicates the Power Query function "unpivot other columns", from the first column, where row labels expand out with their column values.
Functions in this formula: RBYROW, CBYCOL, repeatxtimes (below)
Functions in this formula: RBYROW, CBYCOL, repeatxtimes (below)
Excel Formula:
=LAMBDA(values,num_repeat,
DROP(REDUCE( "",
SEQUENCE(ROWS(values)),
LAMBDA(a, v, VSTACK(a, IF(SEQUENCE(INDEX(num_repeat, v, 1)), INDEX(values, v))))),1)
)
Excel Formula:
=LAMBDA(tableall,
LET(
headers, DROP(CHOOSEROWS(tableall, 1), , 1),
cols, COLUMNS(headers),
rowlabels, DROP(CHOOSECOLS(tableall, 1), 1),
r0s, ROWS(rowlabels),
tabledata, DROP(tableall, 1, 1),
SORTBY(
WRAPCOLS(
TOROW(
IFNA(
VSTACK(
CBYCOL(headers, LAMBDA(x, repeatXtimes(x, r0s))),
SORT(rowlabels),
SORTBY(tabledata, rowlabels)
),
SORT(EXPAND(rowlabels, r0s * 2, , ""))
)
),
cols * r0s
),
RBYROW(rowlabels, LAMBDA(x, repeatXtimes(x, cols)))
)
)
)
Upvote
0