This is a migrated thread and some comments may be shown as answers.

Row count.

7 Answers 794 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 07 Oct 2015, 10:51 PM
I'm trying to find the best way to get a count of rows returned from the data source? I'm trying to put this in a text box. Is there something like =DataSource.Count ?

7 Answers, 1 is accepted

Sort by
-1
Nasko
Telerik team
answered on 09 Oct 2015, 07:37 AM
Hello JET,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Eric
Top achievements
Rank 1
answered on 09 Oct 2015, 04:37 PM

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

0
Nasko
Telerik team
answered on 14 Oct 2015, 12:37 PM
Hello JET,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Raymond
Top achievements
Rank 1
answered on 24 Mar 2016, 04:26 PM

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.

0
Nasko
Telerik team
answered on 25 Mar 2016, 02:22 PM
Hello Raymond,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Adam
Top achievements
Rank 1
answered on 18 Dec 2020, 02:42 PM

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

0
Mads
Telerik team
answered on 23 Dec 2020, 10:20 AM

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/.

Van
Top achievements
Rank 1
commented on 19 Nov 2021, 05:59 PM

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?

Todor
Telerik team
commented on 24 Nov 2021, 10:40 AM

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.

Tags
Report Designer (standalone)
Asked by
Eric
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Eric
Top achievements
Rank 1
Raymond
Top achievements
Rank 1
Adam
Top achievements
Rank 1
Mads
Telerik team
Share this question
or