0
votes

I have SharePoint list called as "Tracker". It has two column one is Month column (which is calculated col) and Duration(which is calculated col). Month has values from Jan to Dec. Duration col contains numeric values. I am trying to get sum of values in duration column for each Month. I tried by getting list items in one array and month values in another array. I am trying to loop in both arrays store values in third array in below format

[{Jan, Sum of Duration in Jan}, {Feb, Sum of Duration in Feb}....]

Pleas help.

Thanks in advance

1
For SharePoint-specific questions, please see the SharePoint Stack Exchange (sharepoint.stackexchange.com) site.P S

1 Answers

0
votes

Ok i solved the above question by using multidimensional array. For looped month column and then in same for loop created second loop for SharePoint list items.

    for (var i = 0; i < monthChoices.length; i++){
        chartSeries[i] = [];
        var monthTotal = 0;
        for(var j= 0; j< arrItems.length; j++ ){
            if(monthChoices[i]==arrItems[j].get_item("Month")  && arrItems[j].get_item("Duration")!= ""){
                monthTotal += arrItems[j].get_item("Duration");
            }
        }
        chartSeries[i].push([monthChoices[i], monthTotal]);
        console.log(chartSeries[i]);
    }