+ Start a Discussion
DnyaneshwarDnyaneshwar 

lead record summary in visualforce page

Hi,

I was trying to get the number of Lead records with XYZ picklist values equals particular values i.e. a table with

       coloumn 1                                  coloumn 2
row1 : ABC              ABC (i.e. count of lead records where field XYZ = A or B or C)
row2 : ACD              ACD (i.e. count of lead records where field XYZ = A or C or D)
row3 : BCD              BCD (i.e. count of lead records where field XYZ = B or C or D)

I tried to acheive this using bucketing in report but couldn't because of salesforce some limitations on bucket fields. So i  am trying to create a vf page table. Any suggestions?

Thanks a Ton! for any help.


 
GarryPGarryP
reports will not help here, as just one records lies in database but it may be present in different criteria hence we cant count same record twice in reports.
You will have to use aggregateResult in apex controller and get the value in page page to display results accourding.
//Pseudo Apex logic
//get count of abc
List<AggregateResult> listAggregateCount1 = [Select count(Id) countid
        from Lead
        where PicklistValue__c in :{'A','B','C'}
        GROUP by Id];
//get count of ACD
List<AggregateResult> listAggregateCount2 = [Select count(Id) countid
        from Lead
        where PicklistValue__c in :{'A','D','C'}
        GROUP by Id];
//get count of BDC
List<AggregateResult> listAggregateCount3 = [Select count(Id) countid
        from Lead
        where PicklistValue__c in :{'B','C','D'}
        GROUP by Id];


use three list of aggregate results to buold VF page


 
DnyaneshwarDnyaneshwar
Hi Girish,

Thanks a lot for the reply.

From yesterday i am trying to get familier with syntax to calculate count of records using AggregateResult and displaying it in a table. but i am more of a admin and in dire need of help in creating this table.

Also in the query above i didn't understand 2 things : 1) count(id) will calculate all record where id is not blank then what is countid    2) We just need the count so do we need group by?

I can hire you as a freelancer if required.
GarryPGarryP
#1 Yes, count(id) is the function that will give count. countid is alisasing that is used for aggregate results
#2. Correct, we need group by clause as per syntax

this is more of syntax of aggregate results sObject.
i will be happy to help you!
email:contriverssoftc@gmail.com
GarryPGarryP
updated code - 
  List<AggregateResult> listAggregateCount1 = [Select count(Id) countid
        from Lead
        where Admission_Status__c in :{'Admission Offered','Admitted','Application on          Hold','Aptitude Test Attempt 1','Aptitude Test Attempt 2','Aptitude Test Attempt         3'} GROUP by Id];  
    
//Integer  AppLeads = aggr[0].get('countid');
​Integer  AppLeads = Integer.valueOf(aggr[0].get('countid'));
​