Count number of times values selected in a dropdown.
Copy link to clipboard
Copied
Hello,
First timer here, trying to automate an incident sheet for our fire co.
I'm trying to create scripts to count the number of members who responded on a certain vehicle.
We have a list of 40 people and there is a drop down next to their name. the dropdown has the vehicles list.
EX: if we have 6 members respond on 52-12 , I would like the script to count the number of times 52-12 was selected in the drop-down and populate that on another field for a total. Simplifying things for the guys.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
What are the names of the dropdown fields?
Copy link to clipboard
Copied
the drop downs are labeled as the person's name (Last,First). the spare at the end are "2" through "10"
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You can use something like this code as the custom calculation script of the text field where you want to show the count of the "5212" values, for example:
var dropdowns = ["Yob, Jordan", "Doe, John"]; // etc.
var total = 0;
for (var i in dropdowns) {
if (this.getField(dropdowns[i]).valueAsString=="5212v1") total++;
}
event.value = total;
Fill in the first line with the actual field names, and notice that the value used in the script is the export value, not the display one.

