Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Row Count in SSRS Report Builder

Tags:

I have built a report using Report Builder 3.0 (that uses SQL Server 2008 R2). Now i wish to now how many records are being fetched from database to the report?

This is possible either by count function in SSRS or by using RANK/ROW_NUMBER function in SQL Query and assigning that as field to the report (RANK/ROW_NUMBER would give us rank to each row and navigating to last page in report would help me getting the total row count).

I tried count function but that counts on some field in the report. For instance = Count(Field!FieldName.value, "DataSetName") Problem in this approach: "FieldName" is not unique in the report and hence the counts get repetitive

Second option: Added Rank/Row_Number but they too use the same kind of fieldName and hence here too the counts get duplicated.

Main Problem: There is no field in my query that is unique (and hence i tried ROW_NUMBER())

How can i find the total row count or rank (for each row) in SSRS 2008?

like image 975
xorpower Avatar asked Feb 03 '12 10:02

xorpower


People also ask

How do I find the row number in SSRS report?

Just right click on Name column then navigate to Insert Column then select Left. Once you select left, you will see a New blank column is added before the Name column. After that, right click on newly added column then select Expression (fx) from context menu.

How do you get total row count?

Just click the column header. The status bar, in the lower-right corner of your Excel window, will tell you the row count. Do the same thing to count columns, but this time click the row selector at the left end of the row. If you select an entire row or column, Excel counts just the cells that contain data.

How do I add a total row in Report Builder?

To add totals for a row group In the tablix data region row group area, right-click a cell in the row group area for which you want totals, point to Add Total, and then click Before or After.

How do I find Rowcount in SQL?

The SQL COUNT() function returns the number of rows in a table satisfying the criteria specified in the WHERE clause. It sets the number of rows or non NULL column values. COUNT() returns 0 if there were no matching rows. The above syntax is the general SQL 2003 ANSI standard syntax.


2 Answers

Use the CountRows function. For example

=CountRows("MyDataset") 

will give you the number of rows in MyDataSet.

like image 108
Jamie F Avatar answered Sep 21 '22 15:09

Jamie F


As someone else mentioned above, I couldn't get CountRows("DatasetName") to work in the header until I wrapped it thusly:CSTR(CountRows("DatasetName")).

like image 23
chainsofthought Avatar answered Sep 18 '22 15:09

chainsofthought