# Calculating How Much Tax Was Added When Only Knowing The Percentage.

Recently I started work on an iPhone app and came across a small problem. As part of the application I needed to know how much tax was added to a value when I only knew the tax percentage and the total after tax. Now if the tax rate was a fixed amount a formula would have been easy to generate (for example the UK has 20% tax so to find the tax paid you simply divide the total by 12 and multiply this by 2), The problem I had is that the tax rate was unknown as it was to be a user input.

I asked a few people and found that nobody I spoke too really knew any way to find this out. Most people suggested just working out the percentage of the total amount however this of course will not work.

Here is how I eventually worked this out :The eureka moment came when it dawned on me that total amount was in fact 100% + tax %. So in the UK example if I had paid £178 which was taxed at 20% then £178 would be 120% of the original figure. On realizing this I found that there were actually 2 ways to work out the pre tax amount.

Method 1

Post Tax Amount = £300
Tax Percentage = 15%
(Post Tax Amount / (100 + Tax Percentage)) * 100
(£300 / (100 + 15)) * 100

OR

(Post Tax Amount * 100) / (100 + Tax Percentage)
(£300 * 100) / (100 + 15)

Basically now that we know that £300 is 115% of the original total we can divide 300 by 115 which will tell us what 1%. To find out the total pre tax amount we multiply this by 100. Alternatively if we need to find out how much tax we paid we multiply the figure we found 1% is and multiply this by 15 (our tax rate in this instance).

From these equations we find the following:

Pre Tax Amount: \$260.87
Tax: £39.15
Post Tax Amount: £300

Method 2

Post Tax Amount = £380
Tax Percentage = 18%
Post Tax Amount – (Post Tax Amount / ((100 + Tax Percentage) / Tax Percentage))
380 – (380 / ((100 + 18) / 18)

This method works in a different way. Instead of working back to find 1% this method determines what ratio the tax percentage is of the total amount. We then divide the post tax amount by this figure (this in fact results in the amount of tax). We then take this latest figure from the post tax amount to find the pre tax amount.

From this equation we get the following result:

Pre Tax Amount: £322.03
Tax: £57.97
Post Tax Amount: £380

Now both of these methods have their advantages and disadvantages and it is for yourself to work out which method is best for you.

Considerations

Now there is a good chance that you will be approaching this from a programming perspective there are a things to consider when putting this into code.

1. How will you handle negative figures
2. How will you handle a 0% as the tax rate (this could result in a division by 0 error)
3. How will you handle rounding issues (you may come across instances where when you round you gain 1 penny or lose a penny).

Hopefully this will help someone, it certainly will help me as I will no doubt forget how I did this.

This site uses Akismet to reduce spam. Learn how your comment data is processed.