当我需要按地图地图中的两个字段/键进行分组时,如何对字段的值求和并添加地图值
我需要根据 Product_Category__c 和每个 Brand_Name__c 的 Volume__c 总和在 VF 中显示不同的表
Below was my controller code please suggest how to populate sum of Volume__c in below map:
list<Rebate_Goal_Brand__c> rebBrand = new list<Rebate_Goal_Brand__c>([SELECT Brand_Name__c,Product_Category__c ,Name,Volume__c FROM Rebate_Goal_Brand__c where Contract__r.name =:contractId and Contract__r.Sales_Org__r.Sales_Org_Code__c='5191' and Product_Category__c != 'Outros']);
for(Rebate_Goal_Brand__c rB: rebBrand)
{
if(!MapGoals.containsKey(rb.Product_Category__c) ){
MapGoals.put(rb.Product_Category__c, new map<string,string>());
}
MapGoals.get(rb.Product_Category__c).put(rb.Brand_Name__c,string.valueOf(rb.Volume__c));
I need to show different table in VF as per Product_Category__c and sum of Volume__c for each Brand_Name__c
Below was my controller code please suggest how to populate sum of Volume__c in below map:
list<Rebate_Goal_Brand__c> rebBrand = new list<Rebate_Goal_Brand__c>([SELECT Brand_Name__c,Product_Category__c ,Name,Volume__c FROM Rebate_Goal_Brand__c where Contract__r.name =:contractId and Contract__r.Sales_Org__r.Sales_Org_Code__c='5191' and Product_Category__c != 'Outros']);
for(Rebate_Goal_Brand__c rB: rebBrand)
{
if(!MapGoals.containsKey(rb.Product_Category__c) ){
MapGoals.put(rb.Product_Category__c, new map<string,string>());
}
MapGoals.get(rb.Product_Category__c).put(rb.Brand_Name__c,string.valueOf(rb.Volume__c));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论