Table.FromColumns Function in Power Query M

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

The Table.FromColumns function in Power Query builds a table from lists, where each list becomes one column. It’s handy when your data is already sitting in lists, or when you want to put columns from different places side by side.

In this article, I’ll show you how to use Table.FromColumns with practical examples, including naming and typing the columns, handling lists of different lengths, and adding a previous-month column to a table.

Follow along with the example file

Table.FromColumns Function Examples.xlsx

Download

Table.FromColumns Function Syntax

= Table.FromColumns(lists as list, optional columns as any) as table
  • lists – a list of lists, such as {{"Ann","Ben"},{82,75}}. Each inner list becomes one column of the table, in the same order.
  • columns (optional) – a list of column names, such as {"Name","Score"}, or a table type, such as type table [Name=text,Score=number], which names the columns and also sets their data types. If you leave it out, the columns are named Column1, Column2, and so on.

What it returns – a table with one column for each list. If some lists are shorter than others, the missing cells are filled with null.

The Table.FromColumns function works in Power Query in Excel for Microsoft 365, 2024, 2021, 2019, 2016, and Excel for Mac (Microsoft 365), as well as in Power BI.

When to Use the Table.FromColumns Function

Use this function when you need to:

  • Type a small table directly in a query, one column at a time
  • Turn separate lists into the columns of one table
  • Put a column from one table next to a column from another table, row by row
  • Add a calculated list, like last month’s values, as a new column
  • Split one long list into several side-by-side columns
  • Convert JSON data that stores each column as a list into a table

Example 1: Create a Table from Lists

Let’s start with the basic use, turning a few lists into a table.

Say you have a bakery’s item names, prices, and the number of items in stock as three separate lists, and you want them as one table.

In the example file, Examples 1 to 4, 8, and 9 are saved as queries only, since they don’t need any worksheet data. You can open them from Data > Queries & Connections.

Create a new blank query (in Excel, go to Data > Get Data > From Other Sources > Blank Query) and use this formula in the formula bar:

= Table.FromColumns({{"Croissant","Bagel","Muffin","Scone"},{3.5,2.25,3,2.75},{24,30,18,12}})

Result: a table with three columns, Column1 (the items), Column2 (the prices), and Column3 (the stock), and one row for each of the four items

Table.FromColumns turns three lists into a table with Column1, Column2 and Column3

Here, the formula has three lists inside an outer pair of curly brackets. Table.FromColumns turns each inner list into a column, so the first list gives Column1, the second gives Column2, and the third gives Column3.

The values line up by position. The first item of each list makes row 1 (Croissant, 3.5, 24), the second item makes row 2, and so on.

Since I didn’t give any column names, Power Query used Column1, Column2, and Column3. The columns also have the Any type, which means no specific data type yet (you’ll see the ABC123 icon in each header).

If your lists hold rows instead (one list per item, like {"Croissant",3.5,24}), use the Table.FromRows function. Table.FromColumns reads each list as a column, while Table.FromRows reads each list as a row.

Example 2: Name the Columns

In Example 1, the columns got generic names. You can give them real names in the second argument.

Say you have a gym’s weekly class schedule as three lists (the days, the classes, and the instructors), and you want a table with Day, Class, and Instructor columns.

Create a new blank query and use this formula:

= Table.FromColumns({{"Monday","Wednesday","Friday"},{"Yoga","Spin","Pilates"},{"Hailey Cooper","Shane Tucker","Travis Sanders"}},{"Day","Class","Instructor"})

Result: a table with Day, Class, and Instructor columns, and one row for each of the three classes

The names list gives the columns the headers Day, Class and Instructor

Here, the second argument is the list {"Day","Class","Instructor"}. The names are matched to the lists by position, so the first name goes to the first list, the second name to the second list, and so on.

You need exactly one name per list. With three lists and only two names, the whole step fails with the error “The count of ‘columns’ (3) doesn’t match that of ‘columnNames’ (2).”

If you give more names than lists, you get the same message with the counts the other way round, such as ‘columns’ (2) and ‘columnNames’ (3).

Example 3: Set the Column Data Types

The column names from Example 2 still leave every column with the Any type. You can name the columns and set their types in the same step.

Say you have three projects with their deadlines and budgets, and you want the Project column as text, Deadline as a date, and Budget as a number.

Create a new blank query and use this formula:

= Table.FromColumns({{"Website Redesign","Office Move","CRM Upgrade"},{#date(2026,4,30),#date(2026,6,15),#date(2026,9,1)},{12000,8500,23000}},type table [Project=text,Deadline=date,Budget=number])

Result: a table with Project (text), Deadline (date), and Budget (number) columns, with the deadlines showing as 4/30/2026, 6/15/2026, and 9/1/2026

The table type gives Project a text type, Deadline a date type and Budget a number type

Here, the second argument is a table type, type table [Project=text,Deadline=date,Budget=number]. It names the three columns and sets their data types, so the headers show the text, date, and number icons.

#date(2026,4,30) creates a real date for April 30, 2026. Power Query shows it in your computer’s regional date format, so a UK machine shows 30/04/2026 for the same date.

Important: A table type labels the columns but doesn’t convert the values. If the Budget list had "12000" (text in quotes), it would still be text, even though the Budget header shows the number icon.

Example 4: Lists of Different Lengths

This is where Table.FromColumns is different from most other ways of building a table. The lists don’t have to be the same length.

Say you have volunteer sign-ups for a charity event, with a separate list of names for the morning, afternoon, and evening shifts. Four people signed up for the morning, two for the afternoon, and three for the evening.

Create a new blank query and use this formula:

= Table.FromColumns({{"Brandon","Teresa","Lori","Julia"},{"Evan","Donna"},{"Jessica","Scott","Tyler"}},{"Morning","Afternoon","Evening"})

Result: a table with Morning, Afternoon, and Evening columns and four rows, where the empty spots show null

The shorter Afternoon and Evening lists are padded with null to match the four morning names

Here, the table gets as many rows as the longest list, which is the morning list with four names. The shorter lists are filled with null at the bottom, so Afternoon has null in rows 3 and 4, and Evening has null in row 4.

There’s no error and no warning about the different lengths.

So if your lists are meant to be the same length, a missing value won’t stop the query. You’ll only spot it as a null in the table.

If you’d rather show a blank or a label instead of null, add a step with the Table.ReplaceValue function to replace null with the text you want.

Example 5: Combine Columns from Two Tables

This next one comes up when two lists are kept in separate tables but belong together row by row.

Below is a Students table (on the Example 5 Students sheet) with the names of five students. I want to put each student’s exam score next to their name.

A Students table with the names of five students

The scores are in a separate Scores table, on the Example 5 Scores sheet, in the same order as the students.

A Scores table with the five exam scores, in the same order as the students

To follow along, select any cell in the Students table and go to Data > From Table/Range to open it in the Power Query Editor. If Power Query adds a Changed Type step, use #"Changed Type" in place of Source in the formula below.

Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:

= Table.FromColumns({Source[Student],Excel.CurrentWorkbook(){[Name="Scores"]}[Content][Score]},{"Student","Score"})

Result: a table with Student and Score columns, where each student has their score next to them (Caroline Williams 88, Curtis Wallace 92, and so on)

Each student now has their score next to them

Here, Source[Student] returns the Student column as a list. Excel.CurrentWorkbook(){[Name="Scores"]}[Content][Score] reads the Scores table from the workbook and returns its Score column as a list.

Table.FromColumns then puts the two lists side by side. The first score goes with the first student, the second score with the second student, and so on.

Important: This matches the rows by position only. If someone sorts the Scores table, the scores land next to the wrong students, so use this only when both lists always stay in the same order.

If both tables have a common column, like a Student ID, merging the tables on that column is the safer choice, since it matches each row by its value.

Example 6: Add a Previous Month Column

Here’s a trick that uses Table.FromColumns to add a new column to an existing table.

Below is a Usage table with the electricity used (in kWh) for each month, and I want to add a Previous kWh column with the usage from the month before.

A Usage table with the kWh used for each month from January to June

Open the table in the Power Query Editor (Data > From Table/Range). If Power Query adds a Changed Type step, use #"Changed Type" in place of Source (in all three places) in the formula below.

Add a new step and use this formula:

= Table.FromColumns(Table.ToColumns(Source)&{{null}&List.RemoveLastN(Source[kWh Used],1)},Table.ColumnNames(Source)&{"Previous kWh"})

Result: the Month and kWh Used columns, plus a Previous kWh column with null for January, 412 for February, 388 for March, and so on

A Previous kWh column shows the usage from the month before, with null for January

Here, the Table.ToColumns function splits the table into a list of its columns. Then & adds one more column to that list.

The new column is wrapped in its own pair of curly brackets, {...}, so & adds it as one extra item (one list) instead of adding its values one by one.

Inside those brackets is {null}&List.RemoveLastN(Source[kWh Used],1). The List.RemoveLastN function drops the last usage value, and {null}& puts a null at the start, so every value moves one row down.

The second argument, Table.ColumnNames(Source)&{"Previous kWh"}, keeps the existing column names and adds the new one. Since each list becomes a column, you get the original table with Previous kWh added on the right.

The new column has the Any type, so set it to Whole Number before you load the table. You can now subtract the two columns to get the change from the month before.

Follow along with the example file

Table.FromColumns Function Examples.xlsx

Download

Example 7: Split a List into Several Columns

Table.FromColumns also works well with a list of lists that you create with a formula.

Below is a Participants table with the names of 12 people who signed up for a workshop. I want to split them into four teams of three, with each team in its own column.

A Participants table with the names of 12 workshop participants

Open the table in the Power Query Editor (Data > From Table/Range), add a new step, and use this formula:

= Table.FromColumns(List.Split(Source[Participant],3),{"Team 1","Team 2","Team 3","Team 4"})

Result: a table with Team 1, Team 2, Team 3, and Team 4 columns, each with three names (Team 1 has Connor, Jacob, and Walter)

The 12 names split into four team columns of three names each

Here, the List.Split function cuts the list of 12 names into smaller lists of three names each. That gives four lists, and Table.FromColumns turns each one into a column.

The team names are typed in, so they only work when you get exactly four lists. If a 13th person signs up, List.Split returns five lists, and the step fails with “The count of ‘columns’ (5) doesn’t match that of ‘columnNames’ (4).”

If the number of people changes often, let Power Query create the team names for you.

Open the Advanced Editor (Home > Advanced Editor) and replace the code with this:

let
Source = Excel.CurrentWorkbook(){[Name="Participants"]}[Content],
Groups = List.Split(Source[Participant],3),
Teams = Table.FromColumns(Groups,List.Transform({1..List.Count(Groups)},each "Team "&Text.From(_)))
in
Teams

Here, the Groups step saves the lists from List.Split, since the next step uses them twice. The List.Count function counts those lists, and {1..List.Count(Groups)} makes a list of numbers from 1 to that count.

The List.Transform function then turns each number into a name, with "Team "&Text.From(_) adding “Team ” in front of the number. With 13 people, you get a Team 5 column with one name and null in the other two rows.

Example 8: Convert JSON Columns into a Table

Some JSON data stores each column as a list, instead of storing one record per row. Table.FromColumns is the easiest way to turn that into a table.

Say you have survey results as JSON text, with a list of questions, a list of Yes counts, and a list of No counts, and you want them as a table.

Create a new blank query, open the Advanced Editor (Home > Advanced Editor), and replace its code with this:

let
Source = Json.Document("{""Question"":[""Easy to use?"",""Fast enough?"",""Would recommend?""],""Yes"":[42,35,51],""No"":[18,25,9]}"),
Survey = Table.FromColumns(Record.FieldValues(Source),Record.FieldNames(Source))
in
Survey

Result: a table with Question, Yes, and No columns, and one row for each of the three questions

The JSON lists become a table with Question, Yes and No columns

Here, the Json.Document function reads the JSON text and returns a record with three fields: Question, Yes, and No. Each field holds a list.

The Record.FieldValues function returns those three lists, which Table.FromColumns turns into columns. The Record.FieldNames function returns the field names (Question, Yes, and No), which become the column headers.

The double quotes inside the JSON text are doubled (""), because that’s how you write a quote inside a text value in M. When the JSON comes from a file or a web address, you don’t need to do this.

Example 9: Build a Week Table from a List of Dates

You can also create every column with a formula, instead of typing the values.

Say you want a planner table for the week starting Monday, January 5, 2026, with the date in one column and the day name in the next.

Create a new blank query, open the Advanced Editor, and replace its code with this:

let
Dates = List.Dates(#date(2026,1,5),7,#duration(1,0,0,0)),
Week = Table.FromColumns({Dates,List.Transform(Dates,Date.DayOfWeekName)},type table [Date=date,Day=text])
in
Week

Result: a 7-row table with Date (1/5/2026 to 1/11/2026) and Day (Monday to Sunday) columns

A 7-row week table with the dates and their day names

Here, the List.Dates function creates a list of seven dates, starting on January 5, 2026, one day apart (#duration(1,0,0,0) is one day). That list is saved in the Dates step.

The List.Transform function then runs the Date.DayOfWeekName function on each date to get its day name. Table.FromColumns puts the dates and the day names side by side, and the table type names the columns and sets their types.

The day names follow your computer’s language settings, so you may see them in another language.

To always get English names, add a culture (a language code like “en-US”). In the code, replace Date.DayOfWeekName inside List.Transform with each Date.DayOfWeekName(_,"en-US").

To make a table for a different week, change the start date in #date(2026,1,5).

Other Excel Articles You May Also Like:

All Power Query Functions

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.