Calculations by Referenced app status
I know how to get a count of how many incoming referenced items from one app are referenced in a single entry in another app. My question: Is there a way to get a count of how many incoming referenced items with a specific category selected in one app are referenced in a single entry in another app.
-
Hi Joe,
yes there is a way:
var cat = @all of your category field;
count = 0;
for(var i = 0; i < cat.length; i++){
if(cat[i] == "XYZ"){
count++;
};
count"XYZ" is a placeholder for the category name. If it is multi choice category field:
if(cat[i].indexOf("XYZ") > -1){
If you want a list of of all categories which have been selected:
var cat = @all of your category field;
var uniqueCat = cat.filter(function(item, pos) {
return cat.indexOf(item) == pos;
});
var list = [];
for(var i = 0; i < uniqueCat.length; i++){
count = 0;
for(var j = 0; j < cat.length; j++){
if(uniqueCat[i] == cat[j]){
count++;
}}
list.push(uniqueCat[i] + ": " + count);
};
list.join("\n")Result:
XYZ: 2
ABC:1
GHI: 3Rainer
Please sign in to leave a comment.
Comments
1 comment