First welcome to the forum
Can't be too specific without seeing your TWBX workbook (see the link Getting Started in the Forums )
in general one way to solve the problem is to create 2 rankings - one ascending the other descending - rank desc = rank_unique(sum(measure 1),'desc') and rank asc = rank_unique(sum(measure 2),'asc') and then use a conditional statement like [rank asc] <+5 or [rank desc]<=5 as a filter set to true
If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution. Thank you.