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.
Brian
P.S. Update: I just found the following , where: @sam.mckay demonstrates a RANKX scenario w/ a virtual table:
Hi @EMNA, we’ve noticed that no response has been received from you since the 14th of April. We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved. If you have a follow question or concern related to this topic, please remove the Solution tag first by clicking the three dots beside Reply and then untick the checkbox. Thanks!