2 separate problems: Find Minimum and a count from a range of numbers while ignoring blanks.
I've got two cells: First is called: MINA. The second cell is called: CNTA.
I've got one column of numbers: Cells are named SR-1, SR-2, SR-3, SR-4....SR-31.
I need a calculation that finds the minimum value in the range[SR-1:SR-31] that I can use in the "MINA" cell. This calculation needs to ignore blanks because not all cells in this range may contain data.
I need a second calculation that counts the number of cells with data in the range[SR-1:SR-31] that I can use in the "CNTA" cell. This calculation also needs to ignore blanks for the same reason.
I needed an average calculation as well and managed to get that to work, for reference, here is that calculation: This calculation was typed in my "AVGA" cell. This one works great with no problems!
-----------------------
// Initialize variables
var i, v, num = 0, sum = 0;
// Loop through the input fields
for (i = 1; i <= 31; i++) {
v = +getField("SR-" + i).value;
if (v !== 0) {
// increment the non-blank/zero field counter
num++;
// add the field value to the running total
sum += v;
}
}
// Calculate the average
if (num) {
event.value = sum / num;
} else {
// All fields are empty, so set to blank
event.value = "";
}
------------------------
I just can't get anything for a Minimum calculation and for a Count calculation to work. Remember...they need to be separate calculations--I cannot combine minimum and count in one calculation.
Thanks in advance anyone who can help!!
