I'm searching for a formula which could rank a value from a subset of a range.

Let's say Col.A is Departement and Col.B is value.

I want a formula which can rank the value from all the other value of this departement.

I have tried things
 `{=rank(value,if(myrange=condition,myrange),0)}`
Does not work.

I have managed to do the oposite - retrieving the value of a certain rank with :

`{=small(if(myrange=condition,myrange),rank i want)}`

I don't understand why my first formula fail.

Excpected result would be the rank of the value from it's subset of value which is all cells where the condition is true.