The problem here is one of evaluation context. DAX measures need to be evaluated against something. The most common way of doing this is in a table or matrix visual, like the one you created here, where AGENCE serves as the evaluation context for your RANKX measure:
When you separate measures from their evaluation context, that’s when things can start to go sideways. However, this doesn’t mean that you always need to show the evaluation context. One of the most powerful features in DAX is the ability to manipulate evaluation context through the use of virtual tables. Thus, you can include a virtual table variable(s) in your measure that provides the proper evaluation context, evaluate your measures and then return results to your visuals without ever showing the evaluation context.
@sam.mckay has a ton of great content on manipulating virtual tables. Here a good intro:
and then a big “deep dive”
I hope this is helpful. If you need additional assistance with this, please provide a copy of your PBIX file and I will be glad to work through a more specific solution with you.
P.S. Update: I just found the following , where: @sam.mckay demonstrates a RANKX scenario w/ a virtual table: