How to get the count, sum, average, maximum, and minimum of numbers in an array.
Contents
Steps
For any calculation, an array of numbers is prepared first.
count
Use the length function in the expression.
length(variables('array'))
sum
A variable for the total is provided with an initial value of 0.
The contents of the array are repeated with "Apply to each".
The "Current item" is added by "Increment variable".
When the iteration is completed, the total value is obtained.
average
Divide the aforementioned total by the number of cases. The division is done with the div function.
Also, when averaging integers, the decimal point will be truncated, float function is also used.
div(float(variables('total')),length(variables('array')))
maximum
Use the max function in the expression.
max(variables('array'))
minimum
Use the min function in the expression.
min(variables('array'))
---
Discussion
New Comments
No comments yet. Be the first one!