0

It is possible to cumulate the aggregate results?

My code below works fine so far, I get for each month a sum of BWS but now I need the cumulative value.

For example: January BWS - 100 February BWS - 250 March BWS - 60 ....

For january I need the value in my chartdata of 100, february 350 and march 410.

Public Class BWS_CY_ChartData {
    Public String BWS_Month { get; set; }
    Public Double BWS { get; set; }

    Public BWS_CY_ChartData(String BWS_Month, Double BWS) {
        this.BWS_Month = BWS_Month;
        this.BWS = BWS;
    }

}

Public List<BWS_CY_ChartData> getBWS_CY_Data() {
    List<BWS_CY_ChartData> data = new List<BWS_CY_ChartData>();

    List<AggregateResult> BWS_List = [SELECT Calendar_Month(Consultingmonth__c) Month, Sum(BWS__c) SumBWS FROM Sales__c WHERE Consultingmonth__c = THIS_YEAR GROUP BY Calendar_Month(Consultingmonth__c) ORDER BY Calendar_Month(Consultingmonth__c)];
    FOR (AggregateResult BWS : BWS_List) {
        data.add(new BWS_CY_ChartData(
            String.valueOf(BWS.get('Month')),
            Double.valueOf(BWS.get('SumBWS')),
     }
     return Data;
}
2
  • Any ideas? Is that possible? If not do you know a workaround?
    – peXeq
    Jul 1, 2019 at 5:36
  • Any help? Please
    – peXeq
    Jul 3, 2019 at 6:34

0

You must log in to answer this question.

Browse other questions tagged .