add numbers with specific category from other app

Answered

Comments

11 comments

  • Rainer Grabowski (FVM)

    This should work:

    var val = @All of number;
    var cat = @All of category;
    var total = 0;
    
    for(var i = 0; i < cat.length; i++){
    if(cat[i] == "a"){
    total += val[i];
    }
    }
    total
    

    Rainer

    0
    Comment actions Permalink
  • Jan Richter

    Thanks Rainer for your fast support, but it sais "keine gültige Zahl" which means "no valid number".

    I remember i tried the exact same script with a for-loop. The Problem is "@All of Number". It's a number field, so I can't say "@All of". I just can say "sum of".

    What should I do?

    0
    Comment actions Permalink
  • Rainer Grabowski (FVM)

    Hi Jan,
    sum of won't work. I use such a calculation very often and don't have problems with "not a valid number"
    Try in the last line
    +total
    or
    parseFloat(total)

    If that doesn't work, please share your calculation here.
    Rainer

    0
    Comment actions Permalink
  • Jan Richter

    Hej Rainer, thanks again for your fast support. I really appreciate it.

    You where right, it works. As you know, when you type "@All of" the calculation field shows possible fields. Number fields are not listed then. When I type the name of the number field, the advices under the field are gone and they do not show up any more. So it's just a word in the end and Podio doesn't connect to the number field. I where able to make it work by typing "@All of" and then past the name. In this case the calculation field shows the the number field as a possible connection. Maybe it's a Safari bug. Is this normal? Do you have the same issue?

    0
    Comment actions Permalink
  • Rainer Grabowski (FVM)

    Hi Jan,

    don't type @all of , but @NumberFieldName, than you should see a list
    sum of
    avg of
    ...
    all of
    for this number field. That works for me in Chrome and Firefox (Windows). It's always faster to type the field name and than to select the right format from the list instead of @all of fieldname

    Rainer

    0
    Comment actions Permalink
  • Jan Richter

    Thank you very much for the advice. That works.

    That was a lot of talk for a small basic thing i didn't know. I think a short tutorial for calculations would be great. I'll post that as a "feature request". The calculation introduction video doesn't really teach the basics and the support told me, that there is nothing in coming.

    Thx, Jan

    0
    Comment actions Permalink
  • Rainer Grabowski (FVM)

    Podio won't do any support for Javascript issues, which is understandable. Here I always find heplful tips and examples (besides Google Search):
    http://www.w3schools.com/js/default.asp
    http://stackoverflow.com/
    http://momentjs.com/docs/

    Rainer

    1
    Comment actions Permalink
  • Jan Richter

    Good to know. Thank you very much.

    Greetz, Jan

    0
    Comment actions Permalink
  • Heather Fox

    Hello, Jan and Rainer. I tried this calculation and keep getting the error "The result is not a valid number." I have tried all 3 ways, using "total", "+total" and "parseFloat(total)" with the same result.

    Here is my calculation:
    var val = @All of Negotiated Price (Number); //this is a number field
    var cat = @All of Status; //this is a category
    var total = 0;

    for(var i = 0; i < cat.length; i++){
    if(cat[i] == "Won"){
    total += val[i];
    }
    }
    total

    Where have I gone wrong? Thanks for your help. :)

    0
    Comment actions Permalink
  • Rainer Grabowski (FVM)

    Hi Heather,

    there could be several reasons. You can try a little trick to "persuade" the calc field to accept your input.
    only change the last line to
    total || 0

    Hope it helps
    Rainer

    1
    Comment actions Permalink
  • Heather Fox

    Perfect! Finally works. Thanks, Rainer!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk