Dec 02 2022 08:16 AM
I was given a long list provided with information containing three columns in order. I need to combine this list to where it stays in order but fill a page at a time. Below is a picture of what i have been given. Any ideas of how i can combine this list to have it more like the other example below.
Dec 02 2022 03:42 PM - edited Dec 02 2022 03:57 PM
@dkent1982 I'm not sure I understand, but if you want to 'wrap' your list and you have excel 365 then I created a LAMBDA function in the attached to do that. The formula is:
ReshapeXrows = lambda(in,rows,LET(i, EXPAND(in,ROUNDUP(ROWS(in)/rows,0)*rows,,""),
DROP(REDUCE("", SEQUENCE(ROUNDUP(ROWS(i)/rows,0),,0,rows),
LAMBDA(u,v, HSTACK(u, CHOOSEROWS(i, SEQUENCE(rows)+v)))),,1)))
so do a print preview of the existing list and zoom in/out to the size you want and see how many rows are shown. Then on new worksheet use above lambda function to create the wrapped version:
=ReshapeXrows( [originalData], [numberRows] )
Then print this new sheet (make sure to set your zoom accordingly or just set to 'fit all rows'
@Patrick2788 , @Hans Vogelaar is there an easier way to make this 'wrap around' function? Am I missing something that already exists?
Dec 03 2022 07:27 AM
Hi Matt, I have Office 2021, so I don't have all these new functions...
Dec 03 2022 09:25 AM
Dec 03 2022 09:35 AM
I have Excel 2013 and i can use all these new functions in Excel for the web.
Dec 03 2022 03:01 PM
This one may be more trouble than it's worth with a LAMBDA. I say this because the solution is not elegant. It's the ol' join/split/wrap approach. My sample is pulling 100 records before wrapping (I realize things go haywire if 110 is selected but I share this Lambda to give an idea of what it takes.). This task would be a lot easier if a matrix could be wrapped:
'HyperWrap
=LAMBDA(arr,records,LET(
w, ROWS(arr) * 3 / records,
joined, BYROW(arr, LAMBDA(row, TEXTJOIN("|", , row))),
bundled, TEXTJOIN("|", , WRAPCOLS(joined, records, "")),
split, TEXTSPLIT(bundled, , "|", , , ""),
WRAPROWS(split, w, "")
))
Dec 03 2022 06:48 PM
Dec 04 2022 08:38 AM
As variant
hWrap = LAMBDA(array, n,
LET(
nR, ROWS(array),
IF(
nR <= n,
array,
LET(
a, hWrap(DROP(array, n), n),
IFNA( HSTACK(DROP(array, n - nR), a), "" )
)
)
)
)
Dec 05 2022 04:57 PM
Dec 06 2022 06:18 AM
Dec 06 2022 09:09 AM
@Patrick2788 So I was looking at ways the function might be improved and noted that I could replace CHOOSEROWS(array of rows) with TAKE(DROP(x)y) and was wondering if that would be better or worse (original followed by variation):
ReshapeXrows = LAMBDA(in, rows,
LET(
i, EXPAND(in, ROUNDUP(ROWS(in) / rows, 0) * rows, , ""),
DROP(
REDUCE(
"",
SEQUENCE(ROWS(i)/rows, , 0, rows),
LAMBDA(u, v, HSTACK(u, CHOOSEROWS(i, SEQUENCE(rows) + v)))
),
,
1
)
)
);
Reshape = LAMBDA(in, rows,
LET(
i, EXPAND(in, ROUNDUP(ROWS(in) / rows, 0) * rows, , ""),
DROP(
REDUCE(
"",
SEQUENCE(ROWS(i)/rows, , 0, rows),
LAMBDA(u, v, HSTACK(u, Take(drop(i, v-1),rows)))
),
,
1
)
)
);
Based on a VERY informal test I believe the CHOOSEROWS is better than the TAKE(DROP())
Dec 06 2022 11:27 AM - edited Dec 06 2022 11:28 AM
CHOOSEROWS does seem a bit faster. TAKE/DROP is a good swap for INDEX in some situations.
Data sample: 20,000 x 1 array
5 timings: .000382 seconds avg
=TAKE(DROP(E1#,10000),10000)
5 timings: .000376 seconds avg
=CHOOSEROWS(E1#,SEQUENCE(10000,,10001))
Dec 13 2022 09:29 AM
I believe recursion stack limit was expanded about an year ago. From 1024 to 16384 if I remember correctly.
Dec 13 2022 10:30 AM