How to count # of records?

silvenwolf
Member Posts: 7
I want to count the number of records per grouping.
I tried CREATETOTALS (but it didn't work) ... I'm working with a string field.
Help please and thanks,
-S.
I tried CREATETOTALS (but it didn't work) ... I'm working with a string field.
Help please and thanks,
-S.
Computers can figure out all kinds of problems, except the things in the world that just don't add up. - James Magary
0
Comments
-
I think you just want to use Record.COUNT for getting the number of records for a grouping. After the filtering is set, Record.COUNT will give you a total.
Are you running this in a report? If so, then COUNTing the records before each grouping loops through isn't as efficient as just using an integer value incremented through the looping through of the records, as long as you don't need that value before the processing of those records.
Cheers!Kristopher Webb
Microsoft Dynamics NAV Developer0 -
You can create one Integer variable and set it to 1.
Than you can use CurrReport.CREATETOTALS(VariableName).
In VariableName you will have the record count for each group and grand total if you will use this varibale in GroupFooter or Footer... ;-)0 -
kine wrote:You can create one Integer variable and set it to 1.
I'm not sure what you are doing here.
I tried a test to just output a list of records from Table 18, creating a basic report using the wizard. I did the setup you suggested, and the first problem I encountered was that CREATETOTALS didn't want to take an integer type variable. Next, adding the value in the GroupFooter didn't automatically update.
For this suggestion, did you mean it would be totalled automatically, or is there more setups/coding that will make this solution work?
Cheers!Kristopher Webb
Microsoft Dynamics NAV Developer0 -
Sorry, create decimal variable...
Yes, if you use CREATETOTALS with some variable, the variable value will be summed after end of OnAfterGetRecord. It is same like TotalFields property for table fields but only with some global variable...
The CREATETOTALS must be in OnPreDataItem section...0 -
Ok, I've done all that you've described so far. Now, the only way for variables to automatically increment that I've seen is to actually display them in one of the body sections. I could, of course, do that, but the original question as I read it was just to get a count. I'm not even 100% sure the original request was about a report! *wink*
Thanks for the info!Kristopher Webb
Microsoft Dynamics NAV Developer0 -
If it is about grouping and CREATETOTALS it is about report... ;-)
The CREATETOTALS do not need to Show the value to be counted.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions