Table.FromColumns
Builds a table from a list of columns, where each column is a list of values.
Table.FromColumns(lists as list, optional columns as any, optional missingField as nullable number) as tableReturns: A new table with one column for each list.
What it does
Table.FromColumns builds a table one column at a time. You give it one list for each column. It suits data that arrives as separate lists, such as a list of months and a list of budget figures that were built in separate steps.
Syntax and arguments
- lists: a list of lists. Each inner list is one column, in braces. Required.
- columns: the column names, in braces. Optional, but recommended.
- missingField: what to do when a name does not match. The default is an error. Optional.
Example
A budget schedule is assembled from two lists: the month names, and the budget amounts for each month, which were calculated in another step.
let
Months = {"Jan", "Feb", "Mar"},
Budget = {10000, 12000, 9000},
Schedule = Table.FromColumns({Months, Budget}, {"Month", "Budget"})
in
Schedule
The first list becomes the Month column and the second becomes the Budget column. The lists must be the same length, so that each row is complete.
Things to watch
- Every list must have the same length. A short list leaves blank cells, which can hide an error.
- The values are not typed by default. Set the types after the step.
- Pair the lists in the same order as the names. Swapping them gives a silent mix-up.
- Query folding: a table built from lists is not a database query. It runs in Power Query.
In business terms
A schedule built from separate lists, such as depreciation by year or a set of planned payments, can be assembled this way and then checked in the query. The lists themselves can be traced back to their calculations.