It appears that there is a bug in the average()
function that is not found in the min, max or sum arithmetic functions. All 4 arithmetic functions work equally well on arrays or just a comma delimited set of values. But average returns the incorrect value when you pass in string-formatted numbers, where as min, max and sum appear to cast the string values into numbers and return the correct results. I’ve confirmed this with a scenario where I input 3 different numbers into the Tools>Basic Trigger module which generates the items as strings only.
In one path I convert the strings into a numeric value with parseNumber()
and the results for all four functions are correct.
In another path I leave the string-formatted values alone and I get a result for average() that is totally wrong! I’m not sure exactly what it is calculating here but sum()
works fine.
With inputs of 25, 35 and 55 (parseNumber() converted strings) generate:
The average is 38.333333333333336 (right!), the minimum is 25,the max is 55 and the sum is 115.
But inputs of “25”, "35 and “55” generates:
The average is 84518.33333333333
(WRONG!), the minimum is 25,the max is 55 and the sum is 115.
Can someone confirm this for me and I can submit the Make bug formally. Here’s the sample scenario – make sure each value in the basic trigger is unique.
average() computation bug for string-formatted numbers.json (16.5 KB)
Also the UI help is incorrect for average(), as arrays are allowed as inputs.