Add a column in with total value calculation field

Comments

1 comment

  • Rainer Grabowski

    Hi Nicolas;

    your above code isn't correct for the case "with nulls" (works only correct if there is no null). Here's the correct code plus the enhancement for the 3. column.

    var name = @All of Name X with nulls;  
    var amount = @All of Amount X with nulls;

    var lines = [];
    var total = 0;
    for(var i = 0; i < name.length; i++){
    var am = Number(amount[i][0]) || 0;
    total += am;
    lines.push(name[i][0] + " | " + am + " | " + total);
    };

    "Name | Amount | Total amount \n" +
    " --- | --- | --- \n" +
    lines.join("\n")

    Rainer

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk