I think you can try TopN function in cluster bar visual directly.
Result is as below.
If you want to achieve your goal by measure, try this code.
VAR _SelectedV =
SELECTEDVALUE ( 'Top N'[Value] )
VAR _RANK =
RANKX ( ALLSELECTED ( 'Sample'[Company] ), [M_Sales] )
ISFILTERED ( 'Top N'[Value] ),
IF ( _RANK <= _SelectedV, [M_Sales], BLANK () ),
By default it will show all values.
Select 5 in slicer, result is as below.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.