1

Instead of using the predefined total options(sum, count, average, maximum, minimum, stdev) I would like to create my own formula and place it in a similar position. Here is a picture of what I was referencing.

enter image description here

What I would like to do is perform a calculation based on two columns and their sums to generate a new result.

In excel it looks like this: =SUM(F13:F17)/(Sum(D13:D17)*3).

Basically, I just want the sum of two entire columns, do some simple division and multiplication, and generate a new result.

If I could place this result above like the predefined totals that came with SharePoint that would be great or somewhere else works. I just need this result to appear somewhere in the list.

Any help is appreciated, thank you!

Edit: In a calculated column, how do I select more than just 1 row? I would like to select all of the rows.

1

All answers in this topic skin the cat

The non-Designer, non-JSlink, non-Data View WebPart way

By whacking some HTML & JavaScript in a Calculated Column

You can get this:

Not suggested for large volume lists, but fine for Views that fit in your display.

Note: It only displays in View, it is not a new Fied value you can continue with

Takes 9 steps and some 15 minutes (or 2 if you just copy/paste the last step)

See: http://www.viewmaster365.com/#/Create/Sum

  • Hi Danny. I'm a little confused by your post. Do I need to download some software before I can begin following these steps? – MMM Aug 1 '16 at 19:30
  • If you are confused then its probably not for you. You don't need any software, no Designer, no Visual Studio, just carefull have to paste code in a Calculated Column.... But as I said... if you don't know what to do then this is not something that matches your skilllevel (and I think even JSLink is easier for you to apply then) – Danny '365CSI' Engelman Aug 1 '16 at 19:47
  • I added it to my bar, then went to my list and clicked on it and it worked. It was added to my style library. Then when I went onto my list and looked in list settings I didn't see anything related to the viewmaster. – MMM Aug 1 '16 at 19:51
  • The ViewMaster does Priority, PercentComplete, Date, NOT the Sum you asked for., That you have to create yourself with the documented steps: viewmaster365.com/#/Create/Sum – Danny '365CSI' Engelman Aug 2 '16 at 6:35
0

You can do this by creating a JSLink file and attaching it to the List View webpart using the webpart properties pane.

Inside the JSLink file you can use somethhing like below

var _totalValue1 = 0.0;
var _totalValue2 = 0.0;
(function () {
    var calculatedFieldCtx = {};       
    calculatedFieldCtx.Templates = {};   
    calculatedFieldCtx.Templates.Fields = {
        "FieldOne": {
            "View": Calculated1
        },
        "FieldTwo": {
            "View": Calculated2
        }
    };   
    calculatedFieldCtx.OnPostRender = [];
    calculatedFieldCtx.OnPostRender.push(function()
    {
        var result = _totalValue1 + _totalValue2 / 3;
        alert(result);
    });
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(
        calculatedFieldCtx
    ); 
})();


function Calculated1(ctx) {       
    _totalValue1 += parseFloat((ctx.CurrentItem.FieldOne));
    return ctx.CurrentItem.FieldOne;
}

function Calculated2(ctx) {       
    _totalValue2 += parseFloat((ctx.CurrentItem.FieldTwo));
    return ctx.CurrentItem.FieldTwo;
}
  • Sorry I'm not very familiar with JSLink. I'm looking to solve this using SharePoint online – MMM Aug 1 '16 at 17:48
  • It works with SPO also.. You can achieve your requirement only via JSOM or JSLink. – Amal Hashim Aug 1 '16 at 17:48
  • @AmalHashim but your approach will only show the sum per page and not per list is this correct? – john Gu May 16 '17 at 12:37
0

You can use calculated column in that case.

  • For the Total you can edit in the View - Total Scores - Select the Calculated Column.
  • Thanks for the fast response. I'm familiar with calculated column but not for this specific example. What syntax would I use to get the sum of an entire column? (there are 5 rows with values in this column I want to add up and divide) – MMM Aug 1 '16 at 17:19
0

Mark Rackley posted a very good explanation of how to do this with SharePoint Designer.

Basically, you use a Data View Web Part to display your information and you can customize the look to show your formulated total.

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.