Reputation: 4779
I have the following value in one of my fileds in SSRS:
=CStr(Fields!Shipment_Weight.Value) + "#"
I do this becuase I need the #(pounds) sign at the end. This now does not allow me to format the number into something like 1,000 it gives me 1000 currently. Is there a way to add commas in the code rather than the format box since this is a string now? Values are all different from 1-1000000000
Thanks!
Upvotes: 4
Views: 33982
Reputation: 8622
As of SSRS 2008 R2, this can be done using FormatNumber(), like so:
=FormatNumber(Sum(Fields!GrossSales.Value),0)
Intellisense shows the following definition:
FormatNumber(
Expression As Object,
Optional NumDigitsAfterDecimal as Int32,
Optional IncludeLeadingDigit as TriState,
Optional UseParensForNegativeNumbers as TriState,
Optional GroupDigits as TriState
) As String
You can then add the "#" to the end:
=FormatNumber(Sum(Fields!GrossSales.Value),0) & "#"
Also available under Common Functions->Text in the Expression editor:
Upvotes: 3
Reputation: 279
I believe the above will work, I've always used the following from MSDN
=CSTR(FORMAT(Fields!Shipment_Weight.Value,"#,#")) & "#"
The article on MSDN about string formatting
Upvotes: 2
Reputation: 4779
I found the answer it is as follows:
=CStr(FORMAT(Fields!Shipment_Weight.Value,"N0")) + "#"
That is how you use formatting code without having to put it in the formatting properties box.
Upvotes: 8