Basically I have been scratching my head trying to accomplish the following:
I have a table full of data, and I want to calculate the highest average of all the rows of that table
So for example if I had
1 4 5 7
3 4 2 6
2 8 1 5
6 3 4 1
I would need to calculate the 4 averages, one per row, and then get the highest one.
(So the averages would be 4.25 , 3.75 , 4 , 3.5 ; and it would choose 4.25 for being the highest)
Keep in mind that the table is periodically getting new data so I cant check a fixed set of rows (I can check a large set of rows and just ignore blank rows)
Also I know a simple solution would be to create a column which would hold all the averages and just get the highest one from there, but the idea is not to create more tables because I need to do way more operations than the average I used as an example here.
Since I couldn’t come up with a solution, I looked into macros and got this (all the variables and declarations are excluded from the paste):
Value = -1000
i = 0
data = range.GetDataArray() // range is a Cell range
while data(i)(0) <> ""
CurrValue = svc.callFunction("Average",data(i)) // svc is createUnoService("com.sun.star.sheet.FunctionAccess")
if Value < CurrValue Then
Value = CurrValue
End if
i = i + 1
WEnd
AFX = ThisComponent.Sheets(0).getCellRangeByName("AF1")
AFX.Value = Value
This works, but I want to know if this result would be achievable with built-in Calc functions.
Thanks.