Forum Discussion
rprsridhar
Feb 12, 2024Brass Contributor
Wrap an array which has two columns
I am using office 365 (family). I have an array output which is 27 rows long and two column wide. I am trying to wrap it dynamically say for eg. after the 13th row to be displayed in the forth and f...
flexyourdata
Feb 12, 2024Iron Contributor
Try this formula:
=LET(
array, B1#,
wrapcount, 13,
totalRows, ROWS(array),
groups, SEQUENCE(ROUNDUP(totalRows / wrapcount, 0), , 0),
first, CHOOSEROWS(array, SEQUENCE(wrapcount)),
REDUCE(
first,
DROP(groups, 1),
LAMBDA(a, b,
HSTACK(
a,
CHOOSEROWS(
array,
SEQUENCE(
MIN(wrapcount, totalRows - b * wrapcount),
,
b * wrapcount + 1
))))))
Or alternatively, as a LAMBDA function:
WRAPROWS_ARRAY = LAMBDA(array, wrapcount,
LET(
totalRows, ROWS(array),
groups, SEQUENCE(ROUNDUP(totalRows / wrapcount, 0), , 0),
first, CHOOSEROWS(array, SEQUENCE(wrapcount)),
REDUCE(
first,
DROP(groups, 1),
LAMBDA(a, b,
HSTACK(
a,
CHOOSEROWS(
array,
SEQUENCE(
MIN(wrapcount, totalRows - b * wrapcount),
,
b * wrapcount + 1
))))))
)
For example: