The concept you are looking for is called "dimensionality," which was a concept first coined in 1822. The simplest way of thinking of dimensionalities is that you cannot add two values unless their dimensionalities are the same.
Thus, if we think in terms of units, 1 foot + 1 meter is a valid addition statement. This is because both foot and meter are units measuring length, a dimensionality. However, 1 foot + 1 second is invalid because the dimensionality of seconds is "time," and you cannot add length + time.
Wikipedia has a nice concise article on the concept of Physical Quantities, which covers the more exacting details.
The SI system recognizes 7 base dimensionalities, from which it derives all others (editor's note: this is in direct conflict with the sourced wikipedia page above.):
- amount of substance
- electric current
- Luminous intensity
Of course, this is not the last words on this topic. Consider planar angle and solid angle (radians and sterradians respectively). Are they units? After much debate in comments below the official answer is no. However, it is extremely common to treat them as units because you get in all sorts of trouble if you treat them as non-units. For example, Iradiannce (W/sr) becomes the same units as Power (W), which is an issue because iradiance and power very often appear in the same document, or the same equation. Confusing one with the other would be a major issue. As pointed out in the comments, wikipedia is even inconsistent in their treatment of angles. Some pages on the SI system treat them as fundamental units, other pages treat them as nothing at all! Boost, in their unit framework for C++, chose to make them full fledged units. Can they get away with it? Maybe. Nobody has every actually axiomized a theory of units which has been considered sufficient by the general body of scientists and engineers. As for the SI system, they gave radians and steradians a special status as "named" derived dimensionless units, recognizing that they are too special to ignore.
On the other hand, some do not even consider luminous intensity to be a true unit. As seen in the comments, there is considerable disagreement as to whether such a human-eye based measure should be a base unit.
It gets murkier once you start entering the world of abstract units. It is not universally agreed upon whether dB is a unit or not, due to its logarithmic nature. Long story short, don't assume these things are set in stone. The real world is quite a lot murkier.