0

Answered

# Array problem

Tuomas 3 years ago
in

**IQANdesign**• updated by Ulrik Zakariasson (Software development) 3 years ago • 4Example: I have array what size is 100 and If I have only 60 measurements there, How I get minimum and average values from these measurements?

ArrayIndexOfMin and ArrayAverage calculates all array 100 values even these empty 40 records and then I get wrong calculations.

How do I get minimum and average values only from records what contains measurements bigger than 0?

Customer support service by UserEcho

Hi,

That is an interesting question. My immediate thought was to start calculating totals using a separate channel, but a more efficient way is to just keep track of the number of posts you have entered, and use these to scale the result from the ArrayAaverage() function.

if Number of points > 0 then

Result := (ArrayAverage(Array channel)/Number of points) *ArrayLength

Attached is a project file that impelments this idea:

Array average of entered posts.ids4

Thank you from your answer.

How about to find minimum value?

Now its find always 0 for minimum (if you have some empty records in array) even real minimum measurement is more than it.

Should I save all measurements to MEM function and compare each measure to MEM value?

If measurement is smaller than MEM value -> reset MEM with new value.

Can you improve Array function to calculate only values greater than 0?

Or make it on option, so you don't have to do extra functions like these examples?

Yes, using a MEM channel would be the way to find the minimum. Something like this:

`if PositiveFlank(Add value) and (Input value < MEM Minimum or MEM Minimum = 0) then`

`QReplace`

`endif`