Anton,
Two recommendations:
1) Go to Tools | Form Options, and on the General tab, set Treat Blank
values as zero.
2) There is a distinction in InfoPath between nodes that are blank and
nodes that do not exist. When you use optional sections, nodes inside
the optional groups are not in the data source until the user explicitly
inserts them; thus, your calculations don't work - they reference nodes
that do not exist. To make your calculations work properly, I would use
conditional formatting to hide "optional" fields/sections - make sure
that each field is present in the data source, and is blank, and your
calculations should work.
Good luck,
Alex @ Microsoft
-----Original Message-----
From: Anton L via OfficeKB.com [mailto:forum@nospam.OfficeKB.com]
Posted At: Wednesday, May 04, 2005 10:02 AM
Posted To: microsoft.public.infopath
Conversation: Formulae that uses optional field values
Subject: Formulae that uses optional field values
I have a formulae for a numeric field that totals up a lot of various
fields from the InfoPath document. Some of the values come from optional
fields. If I don't include any optional fields in the values, the
calculations are OK.
As soon as attempt to include an optional field value, i get NaN as a
result. I tried using filters and ensuring each field "is present" and
"not
blank". However this still causes NaN.
Any ideas or tips, please?
I also have huge trouble with XPath in JS using selectSingleNode when
using
Event functions. Googling hasn't helped so far, but maybe somebody has a
good link to a tutorial?
Anton L - 06 May 2005 04:24 GMT
Thx. I dealt with that by adding some additional data sources and just
refer to them. Not the most elegant solution, but it's ok for the deadline.
Overall, I find it unfortunate that number function in InfoPath cannot by
default convert NaNs to 0s...