SQL Server 2000, RS 2000, Windows 2003

Form a dataset like this:

Name Shots Goals
==== ==== ====
Bob 10 5
Mary 12 2
John 8 3

I need a report that looks like this:

Name Shots/Goals Percent
==== ======== =====
Bob 10/5 50%
Mary 12/2 16%
John 8/3 38%
----------------------------------------
Totals: 30/10 33%
Avg. Pct.: N/A 35%

I can get everything *except* the 35% value on the "Avg. Pct." row. Unlike
the 33% on the Totals row - which is an overll average of Shots/Goals - the
35% is the average of 50, 16 and 38 (the detail rows). To get the 35%, it
seems like I need to do something like this:

=Avg(Sum(Fields!Goals.Value) / Sum(Fields!Shots.Value))

but you cannot nest aggregate functions so this obviously wont work.

Any ideas?

TIA
Craig

RE: SUM of equation by Amarnath

Amarnath
Tue Oct 17 05:29:01 CDT 2006

Just use sum to sum all the percent field (you must have placed a text box in
a table) and divided into no of entries will give you average. it means sum
after the percentage is evaluated by RS and sum the textbox so that 50,16 and
38 will be added and divide with no of items.

Amarnath

"cmeese" wrote:

> SQL Server 2000, RS 2000, Windows 2003
>
> Form a dataset like this:
>
> Name Shots Goals
> ==== ==== ====
> Bob 10 5
> Mary 12 2
> John 8 3
>
> I need a report that looks like this:
>
> Name Shots/Goals Percent
> ==== ======== =====
> Bob 10/5 50%
> Mary 12/2 16%
> John 8/3 38%
> ----------------------------------------
> Totals: 30/10 33%
> Avg. Pct.: N/A 35%
>
> I can get everything *except* the 35% value on the "Avg. Pct." row. Unlike
> the 33% on the Totals row - which is an overll average of Shots/Goals - the
> 35% is the average of 50, 16 and 38 (the detail rows). To get the 35%, it
> seems like I need to do something like this:
>
> =Avg(Sum(Fields!Goals.Value) / Sum(Fields!Shots.Value))
>
> but you cannot nest aggregate functions so this obviously wont work.
>
> Any ideas?
>
> TIA
> Craig

RE: SUM of equation by cmeese

cmeese
Tue Oct 17 13:33:02 CDT 2006

Thanks for the reply.

That's a good thought (and I should have said that I already tried that),
but RS will not let you sum a report item that is not in the Header or
Footer. So, in the footer of the table, I tried this formula:

= Sum(ReportItems!textbox6.Value) / CountRows("DataSetName")

This causes the error about not being able to do aggregate functions on
report items that are not in the header or footer.

Craig

"Amarnath" wrote:

> Just use sum to sum all the percent field (you must have placed a text box in
> a table) and divided into no of entries will give you average. it means sum
> after the percentage is evaluated by RS and sum the textbox so that 50,16 and
> 38 will be added and divide with no of items.
>
> Amarnath
>
> "cmeese" wrote:
>
> > SQL Server 2000, RS 2000, Windows 2003
> >
> > Form a dataset like this:
> >
> > Name Shots Goals
> > ==== ==== ====
> > Bob 10 5
> > Mary 12 2
> > John 8 3
> >
> > I need a report that looks like this:
> >
> > Name Shots/Goals Percent
> > ==== ======== =====
> > Bob 10/5 50%
> > Mary 12/2 16%
> > John 8/3 38%
> > ----------------------------------------
> > Totals: 30/10 33%
> > Avg. Pct.: N/A 35%
> >
> > I can get everything *except* the 35% value on the "Avg. Pct." row. Unlike
> > the 33% on the Totals row - which is an overll average of Shots/Goals - the
> > 35% is the average of 50, 16 and 38 (the detail rows). To get the 35%, it
> > seems like I need to do something like this:
> >
> > =Avg(Sum(Fields!Goals.Value) / Sum(Fields!Shots.Value))
> >
> > but you cannot nest aggregate functions so this obviously wont work.
> >
> > Any ideas?
> >
> > TIA
> > Craig

RE: SUM of equation by Amarnath

Amarnath
Wed Oct 18 02:21:01 CDT 2006

Sometime we tend to think very complex for simple things, I thought you must
have ignored it. Anyways, hey try changing your syntax like this. It should
read this way then it recognizes it.

=Sum(ReportItems("percent").Value)

Amarnath

"cmeese" wrote:

> Thanks for the reply.
>
> That's a good thought (and I should have said that I already tried that),
> but RS will not let you sum a report item that is not in the Header or
> Footer. So, in the footer of the table, I tried this formula:
>
> = Sum(ReportItems!textbox6.Value) / CountRows("DataSetName")
>
> This causes the error about not being able to do aggregate functions on
> report items that are not in the header or footer.
>
> Craig
>
> "Amarnath" wrote:
>
> > Just use sum to sum all the percent field (you must have placed a text box in
> > a table) and divided into no of entries will give you average. it means sum
> > after the percentage is evaluated by RS and sum the textbox so that 50,16 and
> > 38 will be added and divide with no of items.
> >
> > Amarnath
> >
> > "cmeese" wrote:
> >
> > > SQL Server 2000, RS 2000, Windows 2003
> > >
> > > Form a dataset like this:
> > >
> > > Name Shots Goals
> > > ==== ==== ====
> > > Bob 10 5
> > > Mary 12 2
> > > John 8 3
> > >
> > > I need a report that looks like this:
> > >
> > > Name Shots/Goals Percent
> > > ==== ======== =====
> > > Bob 10/5 50%
> > > Mary 12/2 16%
> > > John 8/3 38%
> > > ----------------------------------------
> > > Totals: 30/10 33%
> > > Avg. Pct.: N/A 35%
> > >
> > > I can get everything *except* the 35% value on the "Avg. Pct." row. Unlike
> > > the 33% on the Totals row - which is an overll average of Shots/Goals - the
> > > 35% is the average of 50, 16 and 38 (the detail rows). To get the 35%, it
> > > seems like I need to do something like this:
> > >
> > > =Avg(Sum(Fields!Goals.Value) / Sum(Fields!Shots.Value))
> > >
> > > but you cannot nest aggregate functions so this obviously wont work.
> > >
> > > Any ideas?
> > >
> > > TIA
> > > Craig

RE: SUM of equation by cmeese

cmeese
Fri Oct 20 11:09:02 CDT 2006

I think that's just shorthand syntax for the expression I already tried.
Anyway, it gives me the same error about only being able to use an aggregate
function on reports items in the page header or footer.

Thanks for the reply.

"Amarnath" wrote:

> Sometime we tend to think very complex for simple things, I thought you must
> have ignored it. Anyways, hey try changing your syntax like this. It should
> read this way then it recognizes it.
>
> =Sum(ReportItems("percent").Value)
>
> Amarnath
>
> "cmeese" wrote:
>
> > Thanks for the reply.
> >
> > That's a good thought (and I should have said that I already tried that),
> > but RS will not let you sum a report item that is not in the Header or
> > Footer. So, in the footer of the table, I tried this formula:
> >
> > = Sum(ReportItems!textbox6.Value) / CountRows("DataSetName")
> >
> > This causes the error about not being able to do aggregate functions on
> > report items that are not in the header or footer.
> >
> > Craig
> >
> > "Amarnath" wrote:
> >
> > > Just use sum to sum all the percent field (you must have placed a text box in
> > > a table) and divided into no of entries will give you average. it means sum
> > > after the percentage is evaluated by RS and sum the textbox so that 50,16 and
> > > 38 will be added and divide with no of items.
> > >
> > > Amarnath
> > >
> > > "cmeese" wrote:
> > >
> > > > SQL Server 2000, RS 2000, Windows 2003
> > > >
> > > > Form a dataset like this:
> > > >
> > > > Name Shots Goals
> > > > ==== ==== ====
> > > > Bob 10 5
> > > > Mary 12 2
> > > > John 8 3
> > > >
> > > > I need a report that looks like this:
> > > >
> > > > Name Shots/Goals Percent
> > > > ==== ======== =====
> > > > Bob 10/5 50%
> > > > Mary 12/2 16%
> > > > John 8/3 38%
> > > > ----------------------------------------
> > > > Totals: 30/10 33%
> > > > Avg. Pct.: N/A 35%
> > > >
> > > > I can get everything *except* the 35% value on the "Avg. Pct." row. Unlike
> > > > the 33% on the Totals row - which is an overll average of Shots/Goals - the
> > > > 35% is the average of 50, 16 and 38 (the detail rows). To get the 35%, it
> > > > seems like I need to do something like this:
> > > >
> > > > =Avg(Sum(Fields!Goals.Value) / Sum(Fields!Shots.Value))
> > > >
> > > > but you cannot nest aggregate functions so this obviously wont work.
> > > >
> > > > Any ideas?
> > > >
> > > > TIA
> > > > Craig