Need a measure that will provide the same output as TopN visual level filter (than I can parameterize it).
The solution for simple cases provided HERE
But it doesn't work for more complicated cases...
EXAMPLE:
Don't work if you add any dimension that has Many to One Product Name relationship (Order Number for example).
Desired output: both tables (top and bottom) should be equal:

Example from screen available here HERE
NB! From usability perspective it's preferable to return Sales Rank in measure.


A bit reworked solution from David Bacci:
1. If you need just TopN Sales:
2. If you need Rank for TopN Sales: