Quantcast
Channel: BrainStorage
Viewing all articles
Browse latest Browse all 102

InfoPath 2010 Conditional Formatting Comparisons On Decimal Fields

$
0
0

When working with decimal data in InfoPath forms, especially data coming from SharePoint data sources, you may be surprised to find that your value, for example 38.29, shows up in InfoPath as its floating-point representation. For instance, it might look like 38.2899997478 or something similar.

This behavior can be hidden away by displaying the value in a text field, and then specifying a format to hide the unwanted decimal display. Unfortunately, this approach probably does not work if you need to compare (for equality) this value to another field which also has a decimal value in it.

I was trying to do this on a form that reconciles invoice data. The user inputs an expected total invoice value, then enters a bunch of data to perform calculations and summations. When the user is finished entering data, the calculated total should equal the expected total.

I was using conditional formatting rules to try to change the text color of the two fields (red for not equal, green for equal), and despite the fact that the displayed values were the same, the underlying values were never equal because of the floating-point representation of my calculated value. Fortunately, I found this blog post that provided a workaround that seems to do the trick.

Here is what my updated default value calculation looks like:

decimal_format


Filed under: Form Design, InfoPath, Troubleshooting, XPath and Rules Tagged: Conditional Formatting, Decimal, InfoPath, Workaround

Viewing all articles
Browse latest Browse all 102

Trending Articles