Groups | Blog | Home
all groups > sql server reporting services > december 2004 >

sql server reporting services : Point label - formatting decimal places


cmcdavid
12/2/2004 1:43:02 PM
I have calculated a number of fields with the following method:
=SUM(Fields!Asian.Value) / SUM(Fields!Asian.Value + Fields!Alaskan.Value +
Fields!Black.Value + Fields!Hispanic.Value + Fields!Caucasian.Value +
Fields!AmericanIndian.Value + Fields!NotReported.Value) * 100 & "%" & " Asian"

This gives me my Asian population percentage, but when it renders it carries
on so long that I lose my " Asian" off the chart. I just want to limit the
expression to two decimal places. I tried to put the expression to format
the number in the format code as ##.00 as I would a table to limit the
decimal places to two places. What do I need to do to make this happen?
--
Thanks,
Robert Bruckner [MSFT]
1/30/2005 3:40:37 PM
Not sure if you ever got a response.

The formatcode only works if the datatype of your expression is not a
string. In your example however, the expression will generate a string. Try
to use the FormatNumber function inside the calculation and apply the format
code directly:

=FormatNumber( SUM(Fields!Asian.Value) / SUM(Fields!Asian.Value +
Fields!Alaskan.Value + Fields!Black.Value + Fields!Hispanic.Value +
Fields!Caucasian.Value + Fields!AmericanIndian.Value +
Fields!NotReported.Value) * 100, 2) & "%" & " Asian"

See also:
http://msdn.microsoft.com/library/en-us/script56/html/vsfctFormatNumber.asp

Alternatively you could use the Format function which accepts a format code
as argument. E.g.: =Format( ..., "N2")
See also:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctformat.asp

--
This posting is provided "AS IS" with no warranties, and confers no rights.



[quoted text, click to view]

AddThis Social Bookmark Button