Calculate Spearman and Pearson correlation on variables of different units If for example I have the following data
X     Y
3.2   0
1.5   0
6.5   3
2.4   1
6.2   3

where X is a value between 1 (best case) and 7 (worst case)
and Y is a value between 0 (best case) and 3 (worst case)
and I would like to compute Spearman or Pearson correlation between X and Y.
Do I need to convert into values with similar units?

I take it you are asking whether it makes sense to compute Pearson/Spearman correlations between variables expressed in different units or whether some prior conversion is required instead.
First, neither the Pearson nor the Spearman correlation measures require the variables $X$ and $Y$ to be expressed in the same "units". Actually, if you apply any (invertible) affine transformation to $X$ and $Y$, both these measures of correlation will be unchanged[1]. As a matter of fact, in general we are interested in correlations between incommensurable variables that cannot be expressed in identical units (consider the correlation between, say, Gross Domestic Product in $ and energy consumption in TWh for instance). Therefore it makes sense to seek measures of correlation that would work for such cases.
Still, there is something worthy of being noted that pertains to the scales to which $X$ and $Y$ belong.
Let us say that $X$ is a length. Then the correlation between $X$ and $Y$ should not depend on which unit $X$ is expressed in (e.g. meters or inches or light-years). As a result, the correlation metric should be invariant upon transformations of the form $X\mapsto aX$ (any conversion from one length unit to another). In that case, Pearson and Spearman metrics are a good fit.
Now, let us assume that $X$ is a temperature. Then it should not matter for the correlation whether it is expressed in Celsius, Fahrenheit or kelvin. Then the correlation measure should remain invariant with respect to affine transformations ($X\mapsto aX+b$). Again Pearson and Spearman correlations are invariant wrt such transformations.
However, assume that $X$ now measures something such like the hardness of minerals, in Mohs' scale of hardness for instance. This scale is established by assessing which minerals can scratch which minerals. This allows to "rank" minerals by "hardness", depending on which minerals they can or cannot scratch: the hardness $x_m$ of a material $m$ is larger than that of a material $n$ ($x_m>x_n$) if and only if $m$ can scratch $n$. But that leaves $X$ strongly underdetermined: any monotonically increasing transformation $f$ of $X$ (e.g: $x\mapsto x^2$) preserves the ranking of the materials. So given $X$ as expressed in any scale of hardness (e.g. Mohs' scale), we cannot tell whether it is more warranted than $X^2$, $\exp(X)$, etc. (any monotonically increasing transformation of $X$). However, Pearson's correlation is not invariant with respect to such transformations. Therefore the value or Pearson's correlation between $X$ and $Y$ will in general depend on which hardness scale we use. It is not the case of Spearman's correlation, however. Spearman's correlation remains invariant when monotonically increasing transformations are applied to $X$ or $Y$. So in that case, Pearson's R is less well-founded (because its value will be sensitive to the choice of the scale for $X$, which is somewhat arbitrary), but Spearman's correlation remains a sensible choice.
Coming back to your case, what lesson can you draw from this?

*

*Pearson correlation is invariant with respect to linear and affine transformations1.

*Spearman correlation is invariant with respect to monotonic transformations1 (it is more robust).

*If you cannot tell which variable is more relevant to your problem between, say, $X,X^2$ or $f(X)$ where $f$ is any monotonically increasing transformation  (e.g. as in the case of minerals hardness) than it makes much less sense to calculate Pearson correlations, because the value of R will depend on an arbitrary choice between any of these otherwise physically equivalent scales.

Long-story short: you do not need identical units for computing Pearson or Spearman correlations between variables. However, you need to understand the basic properties of the scales to which they belong, in order to know if it makes sense to use these measures.

1 Up to a sign factor ($\pm 1$)
