Forum Discussion
How to wrap table, not vector (WRAPCOLS for tables)
- Jul 17, 2026
My approach is to leave the table as a 2D array and pull out what's needed in blocks.
=WrapRows2Dλ(DROP(Snapλ(T_Data,"Biology"),,1),4,"")Snapλ is a convenience Lambda for quick filtering without having to supply a Boolean vector.
WrapRows2Dλ has three arguments - array, new_height (4 for this example), and an optional pad_width (empty string here).
WrapRows2Dλ / WrapCols2Dλ: Fast, efficient 2D wrapping without flattening | Microsoft Community Hub
SQL:
create temp table aa as
select (row_number() over ( partition by f01)-1)%4 r ,* from wrap_table;
//select * from aa;
create temp table bb as
select r,f01,group_concat(f02||'</td><td>'||f03||'</td><td>'||f04||'</td><td>'||f05||'</td><td>'||f06,'</td><td>') cols from aa group by r,f01;
select udf_exec_sql('select cols '||f01||' from bb where f01 like '''||f01||'''') 'Data' from wrap_table group by f01;