Tuesday, February 14, 2012

calculating percents in a group header

I am attempting to calculate a percent value in a group header of a report.
My formula looks somethig like:
Iif(sum(Fields.empgolamt.Value,â'table1_Group2â') <> 0,
sum(Fields!empamt.Value,â'table1_Group2â') /
sum(Fields!empgolamt,â'table_Group2â'), 0)
but this results in a divide by zero error. Is there some way to perform
this calculation in a group header or footer (it gives the same error in the
footer).I noticed in your code you are using different datasets to check for
zero and for doing the actual computation. You check the zero condition
in table1_Group2 and then you the denominator comes from table_Group
(without the "1" suffixing "table"). This might be your problem.|||This is just a typo (can't copy and paste from the the expressions window).
The data set referenced in the expression in the report is consistent - there
is only one table in the report.
"Bob" wrote:
> I noticed in your code you are using different datasets to check for
> zero and for doing the actual computation. You check the zero condition
> in table1_Group2 and then you the denominator comes from table_Group
> (without the "1" suffixing "table"). This might be your problem.
>|||There have been many related threads about "division by zero" in this
newsgroup. Please check e.g.:
*
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=3dc7d0e0-d962-47ab-a832-6127ffa45a37&sloc=en-us
*
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.sqlserver.reportingsvcs&mid=c688a5d9-684a-4d54-970a-56a0cb5e7a8d&sloc=en-us
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"reportwriter" <reportwriter@.discussions.microsoft.com> wrote in message
news:C7D4367C-F704-4ACC-95D5-5922DCDEFD1E@.microsoft.com...
>I am attempting to calculate a percent value in a group header of a report.
> My formula looks somethig like:
> Iif(sum(Fields.empgolamt.Value,"table1_Group2") <> 0,
> sum(Fields!empamt.Value,"table1_Group2") /
> sum(Fields!empgolamt,"table_Group2"), 0)
> but this results in a divide by zero error. Is there some way to perform
> this calculation in a group header or footer (it gives the same error in
> the
> footer).
>

No comments:

Post a Comment