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

naijacoder
  • 4,272
  • 26
  • 101
  • 188

3 Answers3

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)

Full explanation at: https://www.365csi.nl/vm365com/#/Create/Sum

Danny '365CSI' Engelman
  • 21,176
  • 7
  • 35
  • 79
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/

Suhayl SH
  • 351
  • 1
  • 6
  • 17
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.

Atish Kumar Dipongkor
  • 13,371
  • 5
  • 32
  • 64
  • 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