How many Items referenced that has multiple specific categories
I have a Whiteboard app where I track my Jobs and a Customer Contact app that references the whiteboard app.
I want to add a calculation field to my Customer Contact app to count how many whiteboard items are categorized as "won" AND "closed".
This is a second separate question: I want to create another calculation field in the Customer Contact app that returns the sum of all of the "Job Total" fields in the Whiteboard app that meets the same criteria above(categorized as "won" AND "closed".)
I've tried some of the solutions online, and I am not sure what I am doing wrong
-
Hi Terry,
I assume "won" and "closed" are categories in the same multi choice category field in the Whiteboard app. And you want to count those whiteboard items where "won" and "closed" are both selected. The code:
var cat = @All of Category; // Replace "Category" with your field name
var count = 0;
for(var i = 0; i < cat.length; i++){
if(cat[i].indexOf("won") > -1 && cat[i].indexOf("closed") > -1){
count += 1;
}
}
countSecond Code:
var cat = @All of Category; // Replace "Category" with your field name
vor jobTotal = @All of Job Total;
var count = 0;
for(var i = 0; i < cat.length; i++){
if(cat[i].indexOf("won") > -1 && cat[i].indexOf("closed") > -1){
count += Number(jobTotal[i]) || 0;
}
}
count -
Rainer Grabowski "won" and "closed" are categories in different single-choice categories. But it didn't work, everything is coming back with zeros
var cat = @All of Estimate Won?;
var stat = @All of Work Status;
var count = 0;
for(var i = 0; i < cat.length; i++){
if(cat[i].indexOf("won") > -1 && stat[i].indexOf("closed") > -1){
count += 1;
}
}
count
Please sign in to leave a comment.
Comments
2 comments