+ Start a Discussion

How to Caluculate Sum of Amount spend by individual per month


I have requirement to display total amount spend by individual per partucular month like shown below, i have Name, Amount__c fields in custom object.  

Name              Current Month Total Amount
Name1                      10000
Name2                        5000
Name3                       40000

if any one can provide me a sample code how to achive this it would be great thankfull.

Thanks In Advance
William TranWilliam Tran
Here you go.

Do a find: "customObject" and replace with your custom object name
<APEX:PAGE standardcontroller="customObject__c" recordsetvar="customObjects__c">

       <apex:pageBlock title="Custom Object"  id="test">
            <apex:pageBlockTable value="{!customObjects__c}" var="co">
                <apex:column headerValue="Name" value="{!co.Name}"/>
                <apex:column headerValue="Amount" value="{!co.Amount__c}"/>

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you. 

Hi William,

Here Amount is sum of amount__c spend by particular user in whole month.

for example: i have user vinod, he has created 5 records(record1 Amount is 10,record2 Amount is 100,record3 Amount is 10,record4 Amount is 250,record5 Amount is 50)in particular month.  now i have to display as below

Name                 Current Month Total Amount
vinod                  420(this value is sum of amount spend by particular user for whole month )
ganesh               1000