Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Table Row Count

Author  Topic 

Peace2007
Posting Yak Master

239 Posts

Posted - 2008-09-01 : 03:09:20
Hi,

I have a table in my report and I need to display number of table rows in a separate field. I don't know how to calculate table rows.
Any idea is appreciated

harlingtonthewizard
Constraint Violating Yak Guru

352 Posts

Posted - 2008-09-02 : 07:37:49
http://weblogs.sqlteam.com/mladenp/archive/2008/02/04/Back-to-Basics-Count-Count-Count-Sum-or-how-to.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-02 : 10:11:35
you can use CountRows() function on dataset and count the number of rows returned to table.
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2008-09-03 : 08:00:38
Thanks all
it works now :)
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2008-09-24 : 07:04:34
CountRows() works fine on regular reports but I'm having a table in my report, which is filtered on a specific value. But CountRows() displays the real rows count. Do you have any idea about how to display filtered table rows?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-24 : 07:28:34
quote:
Originally posted by Peace2007

CountRows() works fine on regular reports but I'm having a table in my report, which is filtered on a specific value. But CountRows() displays the real rows count. Do you have any idea about how to display filtered table rows?


you can use scope information inside countrows
countrows("TableName") should give you the number of rows available in table after filteration.
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2008-09-24 : 07:39:10
I did but it gives this error:
The Value expression for the textbox ‘textbox7’ has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a data set.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-24 : 08:11:16
quote:
Originally posted by Peace2007

I did but it gives this error:
The Value expression for the textbox ‘textbox7’ has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a data set.


isnt textbox linked to some dataset i.e inside a container?
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2008-09-27 : 00:49:44
In textbox properties, I've set Data Region to 'table1', which is the name of the table in my report. And the value of the textbox is set to '=CountRows("table1")'
but I'm given following error:
Error 1 [rsInvalidAggregateScope] The Value expression for the textbox ‘textbox7’ has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a data set.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-28 : 03:50:23
quote:
Originally posted by Peace2007

In textbox properties, I've set Data Region to 'table1', which is the name of the table in my report. And the value of the textbox is set to '=CountRows("table1")'
but I'm given following error:
Error 1 [rsInvalidAggregateScope] The Value expression for the textbox ‘textbox7’ has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a data set.


just add a header row to table and try adding the above expresion to it and see if it works.
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2008-09-28 : 07:17:22
it displays the count of all rows :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-29 : 01:31:30
quote:
Originally posted by Peace2007

it displays the count of all rows :)


even after giving the scope?
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2008-09-29 : 01:55:30
Maybe I'm going into wrong steps; I've inserted a row to the table and set its value to =CountRows("table1").
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-29 : 02:00:45
quote:
Originally posted by Peace2007

Maybe I'm going into wrong steps; I've inserted a row to the table and set its value to =CountRows("table1").


you mean header row or detail row?
Go to Top of Page

Peace2007
Posting Yak Master

239 Posts

Posted - 2008-09-29 : 02:22:00
I'd made a silly mistake, so sorry Visakh I'd filtered the table row instead of the dataset, that's why the CountRows was displaying the whole row count.
I put the filter on the dataset and it works fine now
Thanks a million for your comments
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-29 : 02:51:43
quote:
Originally posted by Peace2007

I'd made a silly mistake, so sorry Visakh I'd filtered the table row instead of the dataset, that's why the CountRows was displaying the whole row count.
I put the filter on the dataset and it works fine now
Thanks a million for your comments


no worries
Glad that you sorted it out
Go to Top of Page
   

- Advertisement -