I am trying to figure out the style string for the Format(Expression as Object, Style as String) function in a Reporting Services expression.
I can't find where these style format strings are documented!
Specifically I am trying to format a Price field to be always 2 decimal places.
ie 1.5 formats to $1.50
Format with Currency format string
=Format(Fields!Price.Value, "C")
It will give you 2 decimal places with "$" prefixed.
You can find other format strings on MSDN: Adding Style and Formatting to a ReportViewer Report
As mentioned, you can use:
=Format(Fields!Price.Value, "C")
A digit after the "C" will specify precision:
=Format(Fields!Price.Value, "C0")
=Format(Fields!Price.Value, "C1")
You can also use Excel-style masks like this:
=Format(Fields!Price.Value, "#,##0.00")
Haven't tested the last one, but there's the idea. Also works with dates:
=Format(Fields!Date.Value, "yyyy-MM-dd")
You can check the schema at
http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition/ReportDefinition.xsd
Search for xsd:complexType name="StyleType"
This will list out all the possible Styles you can use.
Specific to your question however, you can use the Format style.
Format
Specify the data format to use for values that appear in the textbox.
Valid values include Default, Number,
Date, Time, Percentage, and Currency.
Link to MSDN: http://msdn.microsoft.com/en-us/library/ms251684(VS.80).aspx
Have you tried here?
http://msdn.microsoft.com/en-us/library/ms157406.aspx
Give a Format String value of C2 for the value's properties as shown in figure below.
This link has the reference you need to customize your own format
https://msdn.microsoft.com/en-us/library/0c899ak8.aspx
You can set TextBox properties for setting negative number display and decimal places settings.
- Right-click the cell and then click Text Box Properties.
- Select Number, and in the Category field, click Currency.