Calculation in Word Form

J

jon.mullich

I have a Word form that contains a calulation that adds all of the content in
a table row. That was easy enough, by using the =SUM(ABOVE) expression for
the cell that the total goes in.

Now I need to add a cell that contains a discount, so that cell needs to be
subtracted from the others? Is there a simple calculation for that? Can the
number in the cell be added as a begative number?
 
M

macropod

Hi Jon,

Sure can! If you press Alt-F9 to expose your document's field codes, your
existing field should appear, looking like:
{=SUM(ABOVE)}
If your discount is a fixed percentage, you could simply multiply the sum by
the equivalent decimal. For example:
{=SUM(ABOVE)*0.1}
will show a 10% discount, whilst
{=SUM(ABOVE)*0.9}
will show the final amount after deducting the 10% discount.

Now, suppose you've got an existing total that you want to keep, and you
want to show the discount on the next line, and the final amount on the line
below that. In this case, your discount lime could become:
{=-SUM(ABOVE)/2*0.1}
to show the discount as a -ve amount, and
{=-SUM(ABOVE)/2/1.9*0.9}
to show the final amount.

If your discount is something other than 10%, you'll have to play around
with the '1.9' and '0.9' in the last equation. Basically, the '1.9' is
replaced by 2 minus the amount of the discount and the '0.9' is replaced by
1 minus the amount of the discount.

For more information on calculations in Word, check out my Word Field Maths
'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=365442

Cheers
 
J

jon.mullich

That's a great tip, but it doesn't quite respond to my own situation. The
discount isn't a percentage - it's a su. In other words the fields would look
like:

SUM
SUM
DISCOUNTED SUM
SUM
SUM
TOTAL

So if the fields were:
1.00
1.00
2.00
1.00
1.00
TOTAL = 2.00

The total is $2.00 because I've added rows 1,2,4 and 5 aand subtracted row 3.

How can I accomplish this? Can I make row 3 a negative number?
 
G

Graham Mayor

If these are form fields in the table, I would approach this from another
angle. Each form field will have its own bookmark property. Let's assume
Text1 to Text5 here. With Text3 the number to be subtracted.
In the 'total' cell I would enter a calculation

{=({Text1} + {Text2} - {Text3} + {Text4} + {Text5}) \# "$,0.00"}

Check the calculate on exit property of the last form field that contributes
to the calculation.
If you enter a minus amount (-2) in the Text3 form field, all the operators
can be +.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi Jon,

Graham's given you one solution that would certainly work with if you're
using formfields in a document protected for forms.

Even if you're not using such a document, you certainly can use negative
numbers in calculations, and SUM(ABOVE) would do the job just fine for a
table like the one you've described. Things start getting more difficult if
you need sub-totals, but not horribly so. In that case you'd have to rely
the same kinds of formulae you might use in Excel, except that Word doesn't
use '$' symbols to signify absolute references - table cell references in
Word are absolute anyway.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top