[Solved] Calculating values in a query

Creating tables and queries
Post Reply
blokkendoos
Posts: 7
Joined: Mon Apr 14, 2008 11:03 am

[Solved] Calculating values in a query

Post by blokkendoos »

In a form I calculate the VAT with a macro. But before I started using the form I calculated the VAT in a query.
The outcome of these different calculations differed at most 9 cents.
Somehow something went wrong.
The query calculation used the following calculation (T / (100 + v)) * v
The form calculation, checked with Calc, seemed right.
So I changed the query calculation to: (T * v) / (100 + v) and this produces the same outcome as the form calculation!!

Can someone please explain the difference?
T = total including vat
v = vat percentage in the form of an integer (i.e. 19)

tia
pablo k
Last edited by blokkendoos on Sat Feb 21, 2009 12:55 am, edited 1 time in total.
User avatar
TheGurkha
Volunteer
Posts: 6482
Joined: Thu Mar 13, 2008 12:13 pm
Location: North Wales, UK.

Re: calculating values in a query

Post by TheGurkha »

Let S = 100 + v.

What you were doing in (T / (100 + v)) * v was equivalent to ( T / S ) * v

But (T * v) / (100 + v) is equivalent to ( T * v) / S. Note the swapping of the multiply and the divide in the end results.

If this has answered your question please go to your first post and use the Edit button, and add [Solved] to the start of the title. You can use the green tick icon at the same time if you like.
Ubuntu 14.10 Utopic Unicorn, LibreOffice Version: 4.3.3.2
Gurkha Welfare Trust
Post Reply