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

Lead status problem

Hi I want to create one vf page in that i want to show one table with two columns and those are lead owner and ratio of proposed leads by capped leads.

   lead owner                     ratio

proposed is the lead status and capped also lead status .

suppose in a day 10 leads are created in that first owner have  2 are proposed leads and  1 capped lead then we show the ratio of  2/1 for that owner and second owner have 3  proposed leads and 2 capped leads we show the ratio of  3/2 and third owner have 2 proposed leads and 0 capped leads we show the ratio N/A.

      PLZ help me.

You should follow the below steps
1) Query all the leads created today and store it in map of owner id and list of leads.
2) Loop through the map.keyset and then loop through the leads for that lead owner and calculate the ratio there.
3) put in the ratio and the owner in another map of type id and decimal.
4)Use this map to print the values on the VF page.

Thank You .I tried with those steps .

Did it help? If yes then please mark it as a solution for future users

I queried on all leads and put it in map first is k .


the code is


public class CLS_submit {

public Lead le{get;set;}
public map<id,string>leadmp{get;set;}
public list<Lead>leadlst{get;set;}
public list<Lead>leadlst1{get;set;}
public list<Lead>leadlst2{get;set;}
public integer i{get;set;}
public integer j{get;set;}
public decimal k{get;set;}

    public CLS_submit(ApexPages.StandardController controller) {
    leadmp = new map<id,string>();
    leadlst = new list<Lead>();
    leadlst1 = new list<Lead>();
    leadlst2 = new list<Lead>();
    leadlst =[select OwnerId,name from lead where = '00Ed0000000z9IO' AND Status = 'Proposal Sent' AND Lead_ProposalSent_Date__c = today ] ;
    for(lead L:leadlst)
    leadlst1= [select Owner.Name from lead where = '00Ed0000000z9IO' AND Status ='MID Submitted' AND MID_Submitted_Lead_Date__c = today ] ;
   for(lead L:leadlst1)


I cant understand the second step PLZ help me.

Map<ID,List<Lead>> leadMap = new Map<ID,List<Lead>>();
//We need a map of id and list of leads as there can be multiple leads for an owner.
for(lead L: leadlst1){
if(leadmap.get(L.Ownerid) != null){
List<Lead> leadlst = new List<Lead>();
leadlst = leadmap.get(L.Ownerid);
List<Lead> leadlst1 = new List<Lead>();
//This way you have map which has lead owner as key and all the leads it owns as value

for(Id i: leadmap.keyset()){
for(Lead l: leadmap.get(i)){
//Logic to calculate the ratio comes here eg u store the ratio in variable x;
ratiomap.put(i,x);//Use this for the VF page
ratiomap is a map which has owner id as the key and ratio as the value for that owner

here the problem is we want to show lead owner name not id then in the map in place of id i take string but it didn,t allow duplicates PLZ resolve this issue.


Please post the code which you used for the string. Basically now you have the id of the owner and the ratio. You can now manipulate that with whatever you need. You can also create a map with the user object instead of id and then use to get the user name.