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).
>
Showing posts with label header. Show all posts
Showing posts with label header. Show all posts
Tuesday, February 14, 2012
Sunday, February 12, 2012
Calculating grand total in header
I have a report that has a Page Total and a Grand Total in the header.
The Page Total is being calculated from a field in the report like so:
=sum(ReportItems!tcBodyAmount.Value)
where tcBodyAmount is the name I gave the textbox in the report body
that calculates a value.
However, now I need a Grand Total and I can't get the syntax correct.
I've tried summing the PageTotal and I get a different error each time.
I can't use a field in the header. I tried doing a sum on the Page
Total sum but get the error that aggregate functions can't be nested.
I've also tried moving the totals into the body of the report and I get
the error that aggregate functions can only be used in the header and
footer.
The help feature was never loaded so I don't have access to that. Can
anyone give me some guidance on this? Thank you!try a sub report that calcs the total and thats in your header|||I tried that and got a message saying that a subreport can't be placed
in the header or footer|||Try placing in the header
= sum(Fields!Fieldname.Value,"datasetname")
see if that works
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
I support the Professional Association for SQL Server ( PASS) and it''s
community of SQL Professionals.
"Carol" wrote:
> I have a report that has a Page Total and a Grand Total in the header.
> The Page Total is being calculated from a field in the report like so:
> =sum(ReportItems!tcBodyAmount.Value)
> where tcBodyAmount is the name I gave the textbox in the report body
> that calculates a value.
> However, now I need a Grand Total and I can't get the syntax correct.
> I've tried summing the PageTotal and I get a different error each time.
> I can't use a field in the header. I tried doing a sum on the Page
> Total sum but get the error that aggregate functions can't be nested.
> I've also tried moving the totals into the body of the report and I get
> the error that aggregate functions can only be used in the header and
> footer.
> The help feature was never loaded so I don't have access to that. Can
> anyone give me some guidance on this? Thank you!
>|||I had tried exactly that and I get the error message that fields cannot
be called in the header. I even did a search on that one and found an
old posting that said that cannot be done.
I tried the Grand Total as =sum(ReportItems!PageTotal.Value), thinking
that should sum all of the page totals. I didn't get an error, but
instead got no output for both the Grand Total and the Page Total when
I did that. Weird because when I clear that sum, the Page Total prints
fine.
The Page Total is being calculated from a field in the report like so:
=sum(ReportItems!tcBodyAmount.Value)
where tcBodyAmount is the name I gave the textbox in the report body
that calculates a value.
However, now I need a Grand Total and I can't get the syntax correct.
I've tried summing the PageTotal and I get a different error each time.
I can't use a field in the header. I tried doing a sum on the Page
Total sum but get the error that aggregate functions can't be nested.
I've also tried moving the totals into the body of the report and I get
the error that aggregate functions can only be used in the header and
footer.
The help feature was never loaded so I don't have access to that. Can
anyone give me some guidance on this? Thank you!try a sub report that calcs the total and thats in your header|||I tried that and got a message saying that a subreport can't be placed
in the header or footer|||Try placing in the header
= sum(Fields!Fieldname.Value,"datasetname")
see if that works
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
I support the Professional Association for SQL Server ( PASS) and it''s
community of SQL Professionals.
"Carol" wrote:
> I have a report that has a Page Total and a Grand Total in the header.
> The Page Total is being calculated from a field in the report like so:
> =sum(ReportItems!tcBodyAmount.Value)
> where tcBodyAmount is the name I gave the textbox in the report body
> that calculates a value.
> However, now I need a Grand Total and I can't get the syntax correct.
> I've tried summing the PageTotal and I get a different error each time.
> I can't use a field in the header. I tried doing a sum on the Page
> Total sum but get the error that aggregate functions can't be nested.
> I've also tried moving the totals into the body of the report and I get
> the error that aggregate functions can only be used in the header and
> footer.
> The help feature was never loaded so I don't have access to that. Can
> anyone give me some guidance on this? Thank you!
>|||I had tried exactly that and I get the error message that fields cannot
be called in the header. I even did a search on that one and found an
old posting that said that cannot be done.
I tried the Grand Total as =sum(ReportItems!PageTotal.Value), thinking
that should sum all of the page totals. I didn't get an error, but
instead got no output for both the Grand Total and the Page Total when
I did that. Weird because when I clear that sum, the Page Total prints
fine.
Subscribe to:
Posts (Atom)