Suppose you are having following Object and its fields: (Note: Change according to your object and fields) Object: Testobject__c Fields: Rating__c (Interger type) Industry__c (Text type)
Not getting proper of your Key of map requirements, but you can check there two use cases:
Use Case 1: Considering Rating only as a key
Map<Integer, Integer> ratingVsRecordCountMap = new Map<Integer, Integer>();
List<AggregateResult> lstAggResult = [Select Count(Id) ct, Rating__c rt From Testobject__c Group By Rating__c ];
if(!lstAggResult.isEmpty()) {
for(AggregateResult objAgg : lstAggResult) {
ratingVsRecordCountMap.put(objAgg.get('rt') ,objAgg.get('ct'));
}
}
system.debug('your result 1: ' + ratingVsRecordCountMap);
Use Case 2: Considering Rating and industry both together as a key
Hi Neeraj, Thankyou for responding and for your clear explanation. let me explain my requirement.In account object we have rating, industry picklist fields. Now I have to display like table rating picklist values industy picklist values and their corresponding records.
education energy banking insurance Hot 5 6 1 0 Warm 10 3 0 2 Cold 3 5 1 1
like this I have to display for all picklist values of rating and industry. I hope you will get the requirement.
Output: (In My system) { High={In Progress=6, Not Started=1}, Normal={In Progress=3, Not Started=1} } And use this map: ratingVsRecordCountMapOfmap in VF-page to display in your way...
Note: Not considering the those records which not having values for Priority and Status. You can try this meanwhile i will update you for all as you expected.
Plz let me know if it helps you. Mark you ans if meets your expectation.
Suppose you are having following Object and its fields: (Note: Change according to your object and fields)
Object: Testobject__c
Fields: Rating__c (Interger type)
Industry__c (Text type)
Not getting proper of your Key of map requirements, but you can check there two use cases:
Use Case 1: Considering Rating only as a key
Use Case 2: Considering Rating and industry both together as a key
Try this, Hope it will solve your problem.
Thanks
Niraj
Thankyou for responding and for your clear explanation. let me explain my requirement.In account object we have rating, industry picklist fields. Now I have to display like table rating picklist values industy picklist values and their corresponding records.
education energy banking insurance
Hot 5 6 1 0
Warm 10 3 0 2
Cold 3 5 1 1
like this I have to display for all picklist values of rating and industry. I hope you will get the requirement.
You can try this: Plz update object name and fields as per your requiremnets.
Considering:
Priority > rating
Status > industry
Output: (In My system)
{
High={In Progress=6, Not Started=1},
Normal={In Progress=3, Not Started=1}
}
And use this map: ratingVsRecordCountMapOfmap in VF-page to display in your way...
Note: Not considering the those records which not having values for Priority and Status. You can try this meanwhile i will update you for all as you expected.
Plz let me know if it helps you.
Mark you ans if meets your expectation.
Thanks
Niraj
could you write vf page code for this
Could you write the vfpage to display like this.
Notstarted Inprogress
High 2 1
Normal 3 4
I have posted your ans in this link, Try it with some modification
https://developer.salesforce.com/forums?id=9060G0000005l4kQAA
Hope it will help you