Spread sheet registermathmethod custom functions with multidimensional values

Hi,

I found this example on registerMathMethod in the documentations:

For example, let’s create a function “FIRST” that will return the value of the first cell in a range. So, we should add our function to the list as follows:

$$("ss").registerMathMethod("FIRST", function(range){
    return range[0];
});

And we can use the new method as:

=FIRST(H3:H5);

However, this is limited to having one dimensional arrays. H3 to H5

In case I am giving =FIRST(H3:I5) , the argument range comes in as an array of length 6 with 6 values in a single dimensional array. I want it to be a 2 dimensional array so that I know which values belong to which row or column.

Is this supported. Please help!!

Thanks in advance!

Hi @rsant

Unfortunately, there is no such feature. Because math method can get many arguments, including not only cells (for example “=SUM(B3:D5, E6, 2500)”).

So if you need a specific range for each column/row, then you should use such expressions:

“=FIRST(A3:A5)+FIRST(B3:B5)”, for column ranges
“=FIRST(A3:B3)+FIRST(A4:B4)+FIRST(A5:B5)” for row ranges

example: Code Snippet

Thanks for the clarification