Forum Discussion
fakewen
Apr 24, 2023Copper Contributor
What's the easiest way to split a list into a specific number of rows and columns?
For example I have a column with the numbers 1-20, and I want to split it into 3 rows by 4 columns, then the reminder of the rows with 3 columns, while maintaining a horizontal order: 1 2 3 ...
Lorenzo
Apr 24, 2023Silver Contributor
Another option with Power Query with your values formatted as Table (named Table1 below)
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
FromRows = (list as list, columns as number) as table =>
Table.Combine(
List.Transform(
List.Split(list, columns),
each Table.FromRows({_})
)
),
Result = Table.Combine(
{
FromRows(Table.FirstN(Source, 12)[Values], 4),
FromRows(Table.Skip(Source, 12)[Values], 3)
}
)
in
ResultBenefit: the blank cells are really empty (null)