Counting Related Items based on a Category Selection

Comments

5 comments

  • Rainer Grabowski

    Hi Kim,

    this returns the number for "Responded" if Prospect Status is a single choice category field:

    var cat = @all of Prospect Status;
    var sum = 0;
    for(var i = 0; i < cat.length; i++){
    if(cat[i] == "Responded"){
    sum += 1;
    }
    };
    sum

    For other catgories just change cat[i] == "Responded" to cat[i] == "Do Not Contact" etc.
    If it is a multichoice category field:
    cat[i].indexOf( "Responded") > 1

    Rainer

    2
    Comment actions Permalink
  • AEO

    Hey Rainer, 

    For some reason this is not working. Can you please help me?

    0
    Comment actions Permalink
  • Rainer Grabowski

    Your code is ok.
    Which sum did you expect? 
    Do you have a relationship from this app to Offers and also from Offers to this app?
    If so you have 2 tokens @All of Offer Status in the dropdown list. Be sure to select the correct one. 
    Please check how many Offers are related: Enter cat.length as last line in the calculation field. 

    0
    Comment actions Permalink
  • AEO

    I am expecting to get 52."OFFER SENT"

     

    I made sure to to select the correct @All of Offer Status (incoming).

    when I added cat.length to the last line of the calculation field I got the result of 1.

    I believe its only counting how categories are selected within a specific item. I want the calculation to return the sum of all items that have "OFFER SENT" selected.

     

    0
    Comment actions Permalink
  • AEO

    Any solutions for this?

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk