The best way is to break all secondary units into the primary (base) units.
For example, N is a secondary unit which can be broken down into m kg s^-2, and so on.
and joule is N-m, or to the base, m^2 kg s-2
So you can compare the base units to see if they are equivalent.