Revisiting this, I would be remiss if I didn't mention the even more straightforward way to do this by setting a top N filter straight through the UI.
1. Select your visual and open Filters pane
2. Expand filter options of your axis in the filter pane and select the Top N option
3. Select Top N option, add in the measure you want to rank by, and the desired N
Same output as what I provided above. Probably the better solution for its simplicity unless you need the dynamic N functionality I mentioned at the end of my post:
Again, going this route may circumvent your issues because you aren't creating a dynamic table just for the Top N functionality, so you can leverage the measures and relationships you've already set up.