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,
ChrisNot 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.
"cmcdavid" <cmcdavid@.discussions.microsoft.com> wrote in message
news:8E76FFB4-15E6-4ED0-841E-B7C722BC193B@.microsoft.com...
> 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,
> Chris
Showing posts with label sum. Show all posts
Showing posts with label sum. Show all posts
Friday, March 23, 2012
Point label - formatting decimal places
Labels:
calculated,
database,
decimal,
fields,
fieldsalaskan,
fieldsasian,
following,
formatting,
label,
method,
microsoft,
mysql,
number,
oracle,
places,
point,
server,
sql,
sum,
value
Monday, March 12, 2012
PLS HELP! Problem with column width
Hi,
We have a "bad" table in our database - sum of all 30 field widths
exceeds 8000 bytes. It still works fine unless all fields are filled
completely, and that's what happened to one of our clients. Now he can't
do any updates/inserts to the table.
I need to find which row created the problem, so does anybody know how
to get the real length of the row in a table (i mean length of actual
data) other that doing "select len(field1) + len(field2) + etc. from tbl"?
Any ideas are highly appreciated!
Thank you,
MuZZyUse LATALENGTH instead of LEN. And, you can generate that command,if you don
't want to type the
columns:
USE pubs
DECLARE @.tbl sysname, @.sql nvarchar(3000), @.crlf char(2)
SET @.sql = ''
SET @.crlf = CHAR(13) + CHAR(10)
SET @.tbl = 'titles'
SET @.sql = @.sql + 'SELECT TOP 10'
SELECT @.sql = @.sql + @.crlf + ' ISNULL(DATALENGTH(' + name + '), 0) + '
FROM syscolumns
WHERE id = OBJECT_ID(@.tbl)
SET @.sql = LEFT(@.sql, LEN(@.sql) -1)
SET @.sql = @.sql + @.crlf + ' AS theLength'
SET @.sql = @.sql + @.crlf + 'FROM ' + @.tbl
SET @.sql = @.sql + @.crlf + 'ORDER BY theLength DESC'
PRINT @.sql
Edit the sql command printed to add the primary or natural key column and ex
ecute it.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"MuZZy" <tnr@.newsgroups.nospam> wrote in message news:%23VBxDhnWGHA.4768@.TK2MSFTNGP05.phx.g
bl...
> Hi,
> We have a "bad" table in our database - sum of all 30 field widths exceeds
8000 bytes. It still
> works fine unless all fields are filled completely, and that's what happen
ed to one of our
> clients. Now he can't do any updates/inserts to the table.
> I need to find which row created the problem, so does anybody know how to
get the real length of
> the row in a table (i mean length of actual data) other that doing "select
len(field1) +
> len(field2) + etc. from tbl"?
> Any ideas are highly appreciated!
> Thank you,
> MuZZy
We have a "bad" table in our database - sum of all 30 field widths
exceeds 8000 bytes. It still works fine unless all fields are filled
completely, and that's what happened to one of our clients. Now he can't
do any updates/inserts to the table.
I need to find which row created the problem, so does anybody know how
to get the real length of the row in a table (i mean length of actual
data) other that doing "select len(field1) + len(field2) + etc. from tbl"?
Any ideas are highly appreciated!
Thank you,
MuZZyUse LATALENGTH instead of LEN. And, you can generate that command,if you don
't want to type the
columns:
USE pubs
DECLARE @.tbl sysname, @.sql nvarchar(3000), @.crlf char(2)
SET @.sql = ''
SET @.crlf = CHAR(13) + CHAR(10)
SET @.tbl = 'titles'
SET @.sql = @.sql + 'SELECT TOP 10'
SELECT @.sql = @.sql + @.crlf + ' ISNULL(DATALENGTH(' + name + '), 0) + '
FROM syscolumns
WHERE id = OBJECT_ID(@.tbl)
SET @.sql = LEFT(@.sql, LEN(@.sql) -1)
SET @.sql = @.sql + @.crlf + ' AS theLength'
SET @.sql = @.sql + @.crlf + 'FROM ' + @.tbl
SET @.sql = @.sql + @.crlf + 'ORDER BY theLength DESC'
PRINT @.sql
Edit the sql command printed to add the primary or natural key column and ex
ecute it.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"MuZZy" <tnr@.newsgroups.nospam> wrote in message news:%23VBxDhnWGHA.4768@.TK2MSFTNGP05.phx.g
bl...
> Hi,
> We have a "bad" table in our database - sum of all 30 field widths exceeds
8000 bytes. It still
> works fine unless all fields are filled completely, and that's what happen
ed to one of our
> clients. Now he can't do any updates/inserts to the table.
> I need to find which row created the problem, so does anybody know how to
get the real length of
> the row in a table (i mean length of actual data) other that doing "select
len(field1) +
> len(field2) + etc. from tbl"?
> Any ideas are highly appreciated!
> Thank you,
> MuZZy
Wednesday, March 7, 2012
Please Please Please
Hi,
How do i sort on calculate fields?
i have a group which will show the sum of all the details. how do i sort on
the group level ?
EX:
a 55
b 22
c 100
a 55
3
4
3
45
b 22
11
11
c 100
50
50
i want output as
b 22
a 55
c 100
Pls hlep meIn the sorting value of your group, enter this expression :
=Sum(Fields!MyField.Value, "group_name")|||I am doing dynamic sorting - column headers -
and the paramter doesnt take the value of an aggregate.
any other suggestions ?
"Julich" wrote:
> In the sorting value of your group, enter this expression :
> =Sum(Fields!MyField.Value, "group_name")
>|||If dynamic sorting means specifýing the sort column via report parameter
(e.g. "SortBy"), try that as the sorting value for your group:
=Sum(Fields(Parameters!SortBy.Value).Value, "group_name")
"RP" wrote:
> I am doing dynamic sorting - column headers -
> and the paramter doesnt take the value of an aggregate.
> any other suggestions ?
> "Julich" wrote:
> > In the sorting value of your group, enter this expression :
> >
> > =Sum(Fields!MyField.Value, "group_name")
> >
> >
How do i sort on calculate fields?
i have a group which will show the sum of all the details. how do i sort on
the group level ?
EX:
a 55
b 22
c 100
a 55
3
4
3
45
b 22
11
11
c 100
50
50
i want output as
b 22
a 55
c 100
Pls hlep meIn the sorting value of your group, enter this expression :
=Sum(Fields!MyField.Value, "group_name")|||I am doing dynamic sorting - column headers -
and the paramter doesnt take the value of an aggregate.
any other suggestions ?
"Julich" wrote:
> In the sorting value of your group, enter this expression :
> =Sum(Fields!MyField.Value, "group_name")
>|||If dynamic sorting means specifýing the sort column via report parameter
(e.g. "SortBy"), try that as the sorting value for your group:
=Sum(Fields(Parameters!SortBy.Value).Value, "group_name")
"RP" wrote:
> I am doing dynamic sorting - column headers -
> and the paramter doesnt take the value of an aggregate.
> any other suggestions ?
> "Julich" wrote:
> > In the sorting value of your group, enter this expression :
> >
> > =Sum(Fields!MyField.Value, "group_name")
> >
> >
Subscribe to:
Posts (Atom)