Count same item ID repeats in a app
Dear All I would like to count the number of times the same item ID repeats across an app, having in mind that this ID field is a calculation that is pulling the ID from a relationship item. Is this possible via calculation fields? Thanks in advance. Miguel    

  • Hi 3504372038...Your calculation worked pretty nicely. Output sample below. Thanks a lot. On another note, it would be possible, to do the following: To pull the counting number into each Item ID on App A?  Thanks, Miguel -- CRM.10006: 1CRM.9973: 1CRM.10148: 1CRM.10336: 2CRM.10351: 1CRM.10364: 1CRM.10392: 1CRM.10407: 1CRM.10422: 1CRM.10434: 2CRM.10442: 1CRM.10767: 1CRM.10788: 1CRM.10791: 1CRM.11726: 3 ....
  • Hi Rainer. That's exactly my situation. I'll follow your guidelines and revert as soon as possible. Thanks
  • Hi Miguel, as I understand your setup  you have App A with a calculation field that pulls the Item IDs from related items in App B. Now you want to count how often each B-Item ID  occurs in all items of app A. Do I understand your setup right?If so, you would need a third App X with one item and all A-items must be related to that X-item. Then you can use this calculation in X:  var i,j,ids = @all of calculation field in A.join(",").split(",").sort(),arrUni = ids.filter(function(item, pos) {return ids.indexOf(item) == pos;});arrUni = arrUni.sort(function(a, b) { return a - b;});arr = [];for(i = 0; i < arrUni.length; i++){     count = 0;     for(j = 0; j < ids.length; j++){         if(arrUni[i] == ids[j]){           count +=1;        }    }arr.push(arrUni[i] + ": "  + count);};arr.join("\\n") That code works if there is always only one ID in the A-calculation field AND also if there are multiple IDs (separated by a comma) in the A-calculation field. This partarrUni = arrUni.sort(function(a, b) {return a - b;});sorts it so the lowest ID will be at the top of the list.The result is a list like: 100: 2200: 4etcwhere 100 and 200 are the item ids.  Rainer
This question is closed.