function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vivekh88Vivekh88 

Total number of accounts in Reports

Hi,
We have a requirement where we have to show the total number of accounts created during every month and showing the total number of accounts in same table.

                      No.of records for the month    Total number of Account records
Jan 2016                         10                                        30
Feb 2016                         20                                        50
Mar 2016                         40                                        90

Number of accounts for a month i have implemented, but the total no. of account record is possible?

Thanks
Vivek
SandhyaSandhya (Salesforce Developers) 

Hi Vivekh88,

You can use aggregate function COUNT() to get the total records.

Please see below code.
AggregateResult[] arList = [select count(id) from Account];
System.debug(LoggingLevel.INFO, arList[0].get('expr0'));

Please refer below link for more information on aggregate functions.
 
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_agg_functions.htm

Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution. If you felt I went above and beyond, you can give me kudos.

 

Thanks and Regards

Sandhya

 
 
Vivekh88Vivekh88
Hi Sandhya

I need to do this in reports. Is there any option like formula type where i can aggregate total number of accounts and show them in seperate column.

Thanks
Vivek