Forum Discussion
ByRow function produces two different results depending on whether row is range or array
PeterBartholomew1 , hope you are happy with new AFE. Had no time to dig it in details, first impression is quite positive.
Modules, I am pretty comfortable with.
Grid is amazing. Hopefully, I will soon be able to switch the formula bar off forever!
- tdarenkovMar 12, 2023Copper Contributor
I have a similar question. Suppose I have an array (A1#) such that:
2 3 4 I need to create a sequence that in the end looks something like this:
2 2 3 3 3 4 4 4 4 My thought was the use BYROW(A1#,LAMBDA(x,SEQUENCE(1,4,x,0))) so that I get:
2 2 N/A N/A 3 3 3 N/A 4 4 4 4 And then feed that into TOCOL() and use a FILTER() to filter out the "N/A"s. But the function throws a CALC error.
Any thoughts?
- mtarlerMar 12, 2023Silver Contributora) this should really be a new thread (and welcome to add link back to this discussion)
b) if you hover over the error you are probably getting the array of arrays error
c) a common work around here is to use REDUCE() and 'build' the array inside and a drop to get rid of the initial value. e.g. (note this is untested and just off the cuff as an example)
=DROP( REDUCE(0, A1#, LAMBDA( p, q, HSTACK( p, SEQUENCE( q, 1, q, 0) ) ) ), 1)- PeterBartholomew1Mar 12, 2023Silver Contributor
Hi Matt
Going straight for VSTACK would avoid the fill of #N/As.
= DROP( REDUCE(0, seq#, LAMBDA(p, q, VSTACK(p, SEQUENCE(q, 1, q, 0))) ), 1 )
In a properly specified system
= MAP(seq#, LAMBDA(q, SEQUENCE(q, 1, q, 0)))
would work. The 'Nested arrays are not supported' #CALC! error is just plain irritating since the overwhelming majority of solutions I work of have arrays of arrays as their solution. Mind you my requirements have grown since I first encountered the 'array of array failure'. I no longer would want to settle for a row of column vectors, packed into a 2D array. Now I want arrays of 2D arrays, just as one could return with H/VSTACK!