2

Not sure if i would get any answer from here. I have a column number and title text. The data would look like this:

Title  Paid
----------
Jacob  200
Patrick 100
Jacob   100
Patrick 300

What i would like to get is

Jacob: 300
Patrick 400

I was thinking of using a workflow and write the data to another list

Thanks in Advance if anyone has an idea

  • 1
    Where do you need this sum? In a custom web part or in a list view or others. also update the SharePoint version. – Atish Dipongkor - MVP Nov 30 '15 at 6:37
1
  • 2010/2013 No code: Set your view to Group By Title and Sum the Paid Column

  • 2013 CSR (Client Side Rendering) code: UseOnPreRender to loop through the items

  • 2010/2013 Calculated Column: Sum Calculated Column (SP 2013)

(Works in Group View)


(source: viewmaster365.com)

Full explanation at: http://www.viewmaster365.com/#/Create/Sum

0

See if this helps:

SharePoint List: Find Sum, Average on the values with Group By https://rmanimaran.wordpress.com/2011/05/21/sharepoint-list-find-sum-average-on-the-values-with-group-by-3/

0

Client Side Rendering

As DannyEngelman mentioned, you can use CSR for SharePoint 2013. Following snippet may help. I have tested it in OnPreRender

var newValues = [];

ctx.ListData.Row.forEach(function(item) {
    var isDuplicate = newValues.filter(v => v.Title == item.Title);
    if (isDuplicate.length == 0) {
        var hasSameTitle = ctx.ListData.Row.filter(v => v.Title == item.Title);
        var itemsSum = hasSameTitle.reduce((a, b) => parseFloat(a["Paid."]) + parseFloat(b["Paid."]));
        item["Paid"] = itemsSum;
        newValues.push(item);
    }
});

ctx.ListData.Row = newValues;

enter image description here

PS: Not sure IE has support for Arrow functions yet. If it does not have, then you can use callback.

  • How will i use prerender and onrender on this to apply the code ? it is not taking if i simply put the code as js and pass. – OM-ॐ Jun 15 '17 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.