You need to sign in to do that
Don't have an account?

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.
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 .
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 Lead.Owner.UserRole.id = '00Ed0000000z9IO' AND Status = 'Proposal Sent' AND Lead_ProposalSent_Date__c = today ] ;
//system.debug('2222'+leadmp);
for(lead L:leadlst)
{
leadmp.put(L.OwnerId,L.name);
}
leadlst1= [select Owner.Name from lead where Lead.Owner.UserRole.id = '00Ed0000000z9IO' AND Status ='MID Submitted' AND MID_Submitted_Lead_Date__c = today ] ;
//leadlst1.addall(ltdlst);
//leadlst1.addall(leadlst);
for(lead L:leadlst1)
{
leadmp.put(L.OwnerId,L.name);
}
I cant understand the second step PLZ help me.
//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);
leadlst.add(L);
leadmap.put(L.Ownerid,leadlst)
}
else{
List<Lead> leadlst1 = new List<Lead>();
leadlst1.add(L);
leadmap.put(L.Ownerid,leadlst1);
}
}
//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
}
}
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.