This was a very good question. None of the responses were entirely accurate, but by combining them the answer can be revealed. The best answer is that it depends on whether or not the sample you are analyzing is a reference standard or a sample of drug substance. One should see two different equations.
For a reference standard, to determine purity (which is expressed in % usually) necessitates the use of area normalization. Since the HPLC UV detector does not see everything (residual solvents, residue on ignition, counter ion, moisture) this area percent is not on a %w/w basis. However: moisture, ROI, RS, and counter ion are all determined on a %w/w basis. Therefore an equation that just subtracts everything from 100% will not work. The units do not match. See a simplified example below where it is a drug with no counter ion, to simplify the equation:
Assume you have 100 mg reference standard sample. It has 1.0% moisture (%w/w, or 1.0 mg), 0.1% ROI (0.1 mg), and 0.5% RS (0.5 mg). None of the impurities are seen when a solution of the 100 mg is injected onto the HPLC. You are injecting 98.4 mg of visible drug sample. Now let us say you have an organic impurity peak that is 0.2% of the main drug substance peak and assume that the response factor is equivalent to the parent compound. Since this was determined by area normalization, this 0.2% value is of the 98.4 mg. The overall equation you should be using is:
%Purity = (100 - % HPLC impurities)*[(100-%moisture-%ROI-%RS)/100]
In the example above this yields a %purity of 98.2032. You will see that this would give 0.1968 mg for the 0.2% organic impurity value. Once you convert the %organic impurities to mg, you can see that the real value of the purity is 98.2032% via a subtraction equation. For a counter ion example, just subtract this in the numerator where the moisture is. The potency value here is usually expressed in mg/mg, so its answer is 0.982032 mg active/1 mg substance. Notice the difference between potency and purity. Note that using an equation that just subtracts everything would have given an answer of 98.2%: it is close, but since the question was the most accurate way, one can see that there is a difference; An error of -0.00326% in my hypothetical example.
Now, what if you are analyzing a sample? Here, you are comparing the sample to a reference standard which already has a potency determined. Therefore, when you do your calculations to quantify the organic impurity, this potency value goes into the calculation to do so, area normalization is not being used but the sample area compared to the reference standard peak area, and the impurity results is on a %w/w basis. Now the correct equation that is used is just a subtraction:
%Purity = 100-%moisture-%ROI-RS-%organic impurities-%counter ion