7 Answers, 1 is accepted
You can use the Count(Expression) aggregate function which returns a count of the non-null values from the data source. You need to execute the function in the correct data scope to retrieve the number of records in the data source.
Regards,
Nasko
Telerik

I've tried this but that doesn't help with what I'm trying to do. I don't want a count of a particular field I need a count of the rows returned. Could you give me an example. I think what I'm missing is the proper expression. What expression would be used to get a count of rows returned from the data source?
Thanks
In this case, you can pass a static value (e.g. string) to the Count() function and it will return the number of data records for the current data scope. Please find attached a sample report demonstrating the approach.
Regards,
Nasko
Telerik

I used ="Rows Returned: " + Count(1) to get the record count in one of my reports. I put this into a text box at the top and at the bottom of the detail section. There appears to be a bug somewhere depending on the number of rows returned. I tested this varying the number of rows returned up to 4,000 and it worked great. Both the top and bottom row showed the same number and the count was correct. Then I upped the number of rows to 5,000 and got an interesting result. The top row showed a count of 4,552 and the bottom row showed a count of only 448. The actual count should have been 5,000.
What is happening here, and is there a fix for this or is this just too much data for the report designer to handle. I am using the Stand-Alone Report designer 9.0.15.225 from 9/1/2015.
We are not aware of such behavior. In order to investigate further, please open a support ticket where you can send us a sample report with test data exhibiting the issue. Once we manage to reproduce the issue on our end we will start working on it right away.
Regards,
Nasko
Telerik

Can you please help me figure out how to apply this when the data source is tied to a table? I have more problems/frustrations with this aspect of the Report Designer.
If I associate a data source with the report, as in your example, the entire table will appear repeatedly (equal to the number of rows returned by the data source).
However, if the data source is only associated with the table (and not with the report), my table displays the data correctly, but a separate text box will have no access to the fields in the data source.
How can I have a table that is displaying rows of data correctly, and a separate text box showing (for example) a total row count on the same report?
Thanks for your help with this as I'm really hoping to understand this better!
-Adam
Hi, Adam
Applying the datasource to the report itself will make the detail-section repeat for every row of data. If a table is placed inside the detail-section and the datasource is applied to the table as well as the report, the table will be duplicated as you mention.
An approach to achieving what you want is to place the table and the textbox in the header-section of the report. This way, the table will not be repeated, and the textbox still has access to count all the rows of data. By doing this, the detail-section will not be used for anything.
If you want to keep the detail-section available to use for something else, the following can be done:
Insert a List in the report-header. Apply the datasource and then define a group for the List. When defining the value/expression to group by, use something static, like '= 1' to make all the rows into one group. When this is done correctly, the List will not repeat itself for each row of data. A textbox can then be added inside the list with the expression '= Count(Fields.someField)'. Use a field that does not have null values to count every row of data.
Does this work? If the textbox needs to show the count of rows displayed in the table, there are other approaches that can do this. But they are more complicated, so I will explain them if neither of the solutions above is applicable.
Regards, Mads Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
I'm searching for this same solution... get the row count from a table that is in the detail, but show that total in a textbox in the footer.
The above solution talks about adding a list or table to the header, and that doesn't seem to be allowed. The report designer does not allow that. "It is not allowed to add Table to pageHeaderSection1"
Is there a solution for this? Some way to make a report function that can be called from an expression?
Hi Van,
You need to apply the approach in a Report Footer or Report Header section. Indeed, in the Page sections, you are not allowed to add data items.
Generally, the data sources can be accessed only through the data item they are assigned to. That's the reason why you need to use a data item in the section where you should display this total.