if I understand, in a straight table or pivot or tablebox, go to sort tab, sort by expression only
- for Category (change as your req)
=wildmatch(Category, 'XXX', 'YYY', 'ZZZ', '*')
- for Sub-category (change as your req)
=wildmatch(Sub-category, 'A', 'B', '*')
- remove interactive sort
you can get the same result (not in pivot) if you enable interactive sort and sort first by subcategory and then by category
Thanks Massimo for your reply. However, this doesn't work. It gives similar result given by using Match() function which I tried before i.e all categories with sub-category A are displayed first followed by all the categories with sub-category B. I do not want to sort the table by category first and then by sub-category. I want to sort the sub-category in alternate order of its 2 possible values - A and B. I have more than 100 categories, so the output should be category 1 with sub-categories A and B followed by category 2 with sub-categories A and B and so on - as shown in the screenshot of my question.