Table.FromRows 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.FromRows function in Power Query builds a table from lists, where each list becomes one row. It’s a quick way to type a small table straight into a query, and it’s also handy when your data arrives as rows, like JSON from an API.

In this article, I’ll show you how to use Table.FromRows with practical examples, including naming and typing the columns, fixing rows of different lengths, and adding a total row to a table.

Follow along with the example file

Table.FromRows Function Examples.xlsx

Download

Table.FromRows Function Syntax

= Table.FromRows(rows as list, optional columns as any) as table
  • rows – a list of lists, such as {{"Ann",82},{"Ben",75}}. Each inner list holds the values for one row of the table, in column order.
  • columns (optional) – a list of column names, such as {"Name","Score"}, a table type, such as type table [Name=text,Score=number], or a number of columns. If you leave it out (or give a number), the columns are named Column1, Column2, and so on.

What it returns – a table with one row for each inner list.

The Table.FromRows 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.FromRows Function

Use this function when you need to:

  • Type a small table directly in a query, one row at a time
  • Create a lookup or settings table without putting it on a worksheet
  • Reshape a single column of stacked values (like name, phone, city, name, phone, city) into proper rows
  • Generate a table with a formula, such as one row for each month
  • Add a row, like a total row, to the end of an existing table
  • Convert JSON data that stores each row as a list into a table

Example 1: Create a Table from Rows

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

Say you have the rooms at a small hotel, and for each room you know the room number, the room type, and the nightly rate. You want them as a table, with one row per room.

In the example file, Examples 1 to 4, 6, and 8 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.FromRows({{"101","Single",89},{"102","Double",129},{"201","Suite",219},{"202","Double",135}})

Result: a table with three columns, Column1 (the room numbers), Column2 (the room types), and Column3 (the rates), and one row for each of the four rooms

Table.FromRows turns four row lists into a table with Column1, Column2 and Column3

Here, the formula has four lists inside an outer pair of curly brackets. Each inner list becomes one row, so {"101","Single",89} gives row 1, {"102","Double",129} gives row 2, and so on.

Inside each row, the values fill the columns from left to right. The first value goes in Column1, the second in Column2, and the third in Column3.

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).

You’d get the same table if you added ,3 as the second argument, since a number only sets how many columns there are. It doesn’t name them.

If your lists hold columns instead (one list per column, like all the room numbers together), use the Table.FromColumns function. Table.FromRows reads each list as a row, while Table.FromColumns reads each list as a column.

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 three shipping options for an online store, and for each one you know the method, the delivery time, and the cost. You want a table with Method, Delivery Time, and Cost columns.

Create a new blank query and use this formula:

= Table.FromRows({{"Standard","5-7 days",4.99},{"Express","2-3 days",12.99},{"Overnight","1 day",24.99}},{"Method","Delivery Time","Cost"})

Result: a table with Method, Delivery Time, and Cost columns, and one row for each of the three shipping options

The names list gives the columns the headers Method, Delivery Time and Cost

Here, the second argument is the list {"Method","Delivery Time","Cost"}. The names are matched to the values by position, so the first name goes to the first value in every row, the second name to the second value, and so on.

This is a nice way to keep a small lookup table, like shipping rates or tax rates, inside the query itself. You don’t need a separate worksheet for it.

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 invoices with their invoice numbers, invoice dates, and amounts, and you want the Invoice column as text, Date as a date, and Amount as a number.

Create a new blank query and use this formula:

= Table.FromRows({{"INV-1041",#date(2026,3,2),1250},{"INV-1042",#date(2026,3,9),480},{"INV-1043",#date(2026,3,16),2175}},type table [Invoice=text,Date=date,Amount=number])

Result: a table with Invoice (text), Date (date), and Amount (number) columns, with the dates showing as 3/2/2026, 3/9/2026, and 3/16/2026

The table type gives Invoice a text type, Date a date type and Amount a number type

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

#date(2026,3,2) creates a real date for March 2, 2026. Power Query shows it in your computer’s regional date format, so a UK machine shows 02/03/2026 for the same date.

Important: A table type labels the columns but doesn’t convert the values. If an amount was typed as "1250" (text in quotes), it would stay text, even though the Amount header shows the number icon.

Example 4: Fix Rows of Different Lengths

Every row needs the same number of values, and it’s easy to miss one.

Say you have a contact list with each person’s name, phone number, and email address. But one person, Jasmine Watson, didn’t give an email, so her row only has two values.

Create a new blank query and use this formula:

= Table.FromRows({{"John Perry","555-0124","john.perry@example.com"},{"Bradley Graham","555-0187","bradley.g@example.com"},{"Jasmine Watson","555-0148"},{"Denise Wells","555-0162","denise.wells@example.com"}},{"Name","Phone","Email"})

Result: the table has all four rows, but every cell in Jasmine Watson’s row shows Error

Jasmine Watson's row has only two values, so every cell in that row shows Error

Here, Table.FromRows doesn’t fill the missing email with null. It turns the whole row into an error, with the message “3 keys were specified, but 2 values were provided.”

The other rows still work fine, so the step itself doesn’t fail. When you load the table to a worksheet, the error row comes through blank, which makes the problem easy to miss.

The same thing happens when a row has too many values. A four-value row in a three-column table gives “3 keys were specified, but 4 values were provided.”

To fix this, add null to the end of every short row before building the table. Open the Advanced Editor (Home > Advanced Editor) and replace the code with this:

let
Rows = {{"John Perry","555-0124","john.perry@example.com"},{"Bradley Graham","555-0187","bradley.g@example.com"},{"Jasmine Watson","555-0148"},{"Denise Wells","555-0162","denise.wells@example.com"}},
Padded = List.Transform(Rows,each _&List.Repeat({null},3-List.Count(_))),
Contacts = Table.FromRows(Padded,{"Name","Phone","Email"})
in
Contacts

Result: the same contact table, with null in Jasmine Watson’s Email cell and no errors

After padding the short row with null, the table has no errors and Jasmine Watson's Email is null

Here, the Rows step holds the four rows. In the Padded step, the List.Transform function goes through the rows one at a time, and each runs the code after it on every row, with _ standing for the row it’s working on.

So 3-List.Count(_) counts the values in that row and works out how many are missing (0 for full rows, 1 for Jasmine’s row).

The List.Repeat function makes a list with that many nulls, and & adds them to the end of the row. Every row now has three values, so Table.FromRows builds the table without errors.

Important: The 3 in 3-List.Count(_) must match the number of column names, so change it if you add or remove a column. A row with more values than that shows the error “The ‘count’ argument is out of range.” instead of losing the extra value.

Example 5: Turn a Single Column into Rows

Here’s a problem that comes up a lot when you copy data from a web page or a PDF. Each record ends up stacked in one column, one value per cell.

Below is a ContactList table with one column, Contact Details. Every three cells hold one person’s name, phone number, and city, and I want a table with Name, Phone, and City columns.

A ContactList table with each person's name, phone and city stacked in one column

To follow along, select any cell in the 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.FromRows(List.Split(Source[Contact Details],3),{"Name","Phone","City"})

Result: a table with Name, Phone, and City columns, and one row for each of the four people (Jeremy Fisher, 555-0119, Denver in the first row)

The stacked values become a table with Name, Phone and City columns, one row per person

Here, Source[Contact Details] returns the column as a list of 12 values. The List.Split function cuts it into smaller lists of three values each, so you get four lists, one for each person.

Each of those lists is exactly the shape Table.FromRows needs for a row. So it turns them into four rows, and the second argument names the three columns.

Important: This only works when every person has all three values. If one phone number is missing, every value after it shifts up by one cell, and the last row shows an error because it’s one value short.

Example 6: Generate a Table with a Formula

You don’t have to type every row by hand. You can also create the rows with a formula.

Say you want a table of the 12 months of 2026, with the month number, the month name, and the number of days in each month.

Create a new blank query and use this formula:

= Table.FromRows(List.Transform({1..12},each {_,Date.MonthName(#date(2026,_,1)),Date.DaysInMonth(#date(2026,_,1))}),type table [Number=Int64.Type,Month=text,Days=Int64.Type])

Result: a 12-row table with Number (1 to 12), Month (January to December), and Days columns, where February has 28 days

A 12-row month table with the month number, month name and number of days

Here, {1..12} is a list of the numbers 1 to 12. The List.Transform function turns each number into a row, so for 2 you get {2,"February",28}.

Inside that row, #date(2026,_,1) is the first day of the month. Date.MonthName returns its name, and Date.DaysInMonth returns how many days that month has.

Table.FromRows then stacks the 12 rows into a table, and the table type names the columns and sets their types (Int64.Type is a whole number).

The month names follow your computer’s language settings. To always get English names, use Date.MonthName(#date(2026,_,1),"en-US") instead.

Follow along with the example file

Table.FromRows Function Examples.xlsx

Download

Example 7: Add a Total Row to a Table

Since Table.FromRows can build a one-row table, you can use it to add a row to the end of an existing table.

Below is an Expenses table with the monthly amount for five categories, and I want to add a Total row at the bottom.

An Expenses table with the monthly amount for five categories

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.Combine({Source,Table.FromRows({{"Total",List.Sum(Source[Amount])}},Table.ColumnNames(Source))})

Result: the five expense rows, plus a sixth row with Total in the Category column and 2795 in the Amount column

A Total row with 2795 is added at the bottom of the Expenses table

Here, {{"Total",List.Sum(Source[Amount])}} is a list with one row in it. The List.Sum function adds up the Amount column, so the row is Total and 2795.

Table.ColumnNames(Source) gives that one-row table the same column names as the Expenses table (Category and Amount). That matters, because the Table.Combine function matches columns by name when it stacks the two tables.

If the names didn’t match, Table.Combine would add new columns instead of putting the total under Amount.

Example 8: Convert JSON Rows into a Table

Some web APIs send data as a list of column names plus a list of rows, where each row is a list of values. Table.FromRows is made for this shape.

Say you have website traffic as JSON text, with a list of column names and three rows of daily numbers, 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("{""columns"":[""Date"",""Visitors"",""Sign-ups""],""rows"":[[""2026-03-02"",412,18],[""2026-03-03"",388,15],[""2026-03-04"",455,22]]}"),
Traffic = Table.FromRows(Source[rows],Source[columns])
in
Traffic

Result: a table with Date, Visitors, and Sign-ups columns, and one row for each of the three days

The JSON rows become a table with Date, Visitors and Sign-ups columns

Here, the Json.Document function reads the JSON text and returns a record with two fields. The columns field holds the list of column names, and the rows field holds a list of three rows.

Source[rows] is already a list of lists, so Table.FromRows can use it as is. Source[columns] gives the column names.

The dates come through as text, such as 2026-03-02, because JSON has no date type. Change the Date column’s type to Date before you load the table.

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.

Other Excel Articles You May Also Like:

  • Table.FromRecords – Use Table.FromRecords in Power Query M to build a table from records.
  • Table.FromList – Use Table.FromList in Power Query M to turn a list into a table.
  • Table.ToList – Use Table.ToList in Power Query M to turn each table row into one value.
  • Table.ExpandListColumn – Use Table.ExpandListColumn in Power Query M to turn lists into rows.
  • Table.Pivot – Use Table.Pivot in Power Query M to turn row values into columns.
  • Table.Unpivot – Use Table.Unpivot in Power Query M to turn columns into rows.
  • Table.ExpandTableColumn – Use Table.ExpandTableColumn in Power Query M to expand merged table columns.
  • Table.UnpivotOtherColumns – Use Table.UnpivotOtherColumns in Power Query M to turn columns into rows.

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.