I’m working on developing a series of reports. These reports require various columns to be formatted for numbers, currency, percentages, etc etc.
Typically to accomplish this I use an expression, something like:
=FormatPercent(Fields!NewItems.Value,2)
This works just fine. I’ve just recently become aware of a Format property on the text box that takes in a format string such as p2 for the example above.
Are there specific cases for using the expression over the property? The property is slightly more cryptic, requiring the dev to know the valid format strings, but it’s also faster to simply enter p2 for a group of text boxes rather than going into the expression of each one individually.
Use the Format property whenever you can. This will have the best support for export formats, such as Excel.
If you use an expression, as in your example, then the value being exported will really be a string, and Excel will need to parse it to get back the original value. If you use the format property, then the original numeric value will go to Excel with formatting instructions. Then the user can choose to alter the format as needed, such as changing the rounding.
The expressions are much more flexible so it isn’t hard to come up with formats that can be handled by expression and not with the Format property. So there are times that using an expression is required.