Calculation field - if this then Total, if this then average

Comments

2 comments

  • Rainer Grabowski

    Hi Rachel,

    this should work:

    var cat = @All of the category field;
    var val = @All of Quoted Value;
    var sumPencil = 0;
    var sumOpt = 0;
    var numberOpt = 0;
    for(var i = 0; i < cat.length; i++){
        if(cat[i] == "Pencil){
         sumPencil += Number(val[i]) || 0;
        }
        if(cat[i] == "Option"){
        sumOpt += Number(val[i]) || 0;
        numberOpt += 1;
      }
    };
    var sumOpt = sumOpt > 0 ? (sumOpt/numberOpt) : 0;
    var total = sumPencil + sumOpt;
    total

    Rainer

    0
    Comment actions Permalink
  • Rachel Gretton

    Thank you so much Rainer, this works perfectly! 

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk