how do I add the results of an expression in infopath

E

elgar22

Using Inforpath 2003 with SP1

I want to make an order form that can caluculate the total amount for each
item ordered using an expression, I also want a overall total of all items. I
can sum a column of numbers but is there a way to sum a column of expressions?

Thanks
 
S

Scott L. Heim [MSFT]

Hi,

You can use the "Sum" function in your total field but it will need to use
the same basic expression as the original Expressions Boxes. For example,
let's say you have an Expression Box for each line item that uses the
following expression:

my:field1 + my:field2

If you wanted to have a final Expression Box that totaled all of these Line
Item expressions, it would look like the following:

sum(field1) + sum(field2)

** NOTE: This is using the built-in "builder" - the actual XPath expression
for this is as follows:

sum(my:group1/my:group2/my:field1) + sum(my:group1/my:group2/my:field2)

I hope this helps!

Best Regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
R

Renee in Juneau

You'll make life SO much easier on yourself if you store the item's
total amount in a field rather than strictly as an expression box
value. If you don't want to have item totals as part of your schema,
create a secondary schema and store them there as a set of related
throwaway values.
 
E

elgar22

Thanks for the input, Renee, but I'm pretty new to Infopath and don't really
understand the idea of schemas without seeing it. Scott's solution seems like
something I can cope with. I have fields Quantity, Unit Price and Amount
where my original expression in amount is "my:No*my:price" what would my
expression look like to sum all of these calculation?
 
R

Renee in Juneau

Yeah, I'm pretty new to Infopath, too, but the flexibility of the
product fascinates me. My big push with respect to forms right now is
to learn Xpath and XSLT so I can really leverage things (while saving
lots of time).

Anyway, if you were storing Item_Total in a (some numeric format)
textbox rather than as an expression box, I think all you'll need is
to create a rule on the Grand_Total textbox (which is also set to some
numeric format and is placed outside the repeating table, right?).

This one rule would always apply. The action would be "Set A Field's
Value". The field would be itself and the value would be
"sum(Item_Total)"
 

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