Forum Discussion
PIVOTBY Table with custom sorting
- Mar 02, 2025
I don't think there are any shortcuts but once you are into the 365 environment with LET you can define variables to use in place of helper ranges.
= LET( index, XMATCH(Category, CategoryOrder), crosstab, PIVOTBY(index, Year, Amount, SUM), rowHdr, IFERROR(INDEX(CategoryOrder, TAKE(crosstab,,1)),""), HSTACK(rowHdr, DROP(crosstab,,1)) )Here index is used for to sort the row categories and, once done, look up the appropriate row header.
Thanks so much for your prompt response, Peter.
I have the following table made by PIVOTBY.
I would love to have the rows arranged by this type of order.
I understood what you suggested earlier, which is adding one more column in the data indicating the sorting order, did I understand it right?
Is there any short-cut rather than adding one more column in dataset? Thanks,
I don't think there are any shortcuts but once you are into the 365 environment with LET you can define variables to use in place of helper ranges.
= LET(
index, XMATCH(Category, CategoryOrder),
crosstab, PIVOTBY(index, Year, Amount, SUM),
rowHdr, IFERROR(INDEX(CategoryOrder, TAKE(crosstab,,1)),""),
HSTACK(rowHdr, DROP(crosstab,,1))
)Here index is used for to sort the row categories and, once done, look up the appropriate row header.
- tanacalMar 02, 2025Brass Contributor
Thanks, Peter. Appreciated!
Thanks for sharing your workbook so I can go thru it step by step.