Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Table.RenameColumns takes two values -- the table you want to modify, and a list (or list of lists) containing the old and new column names.
Example given in Power Query documentation:
Replace the column name "CustomerNum" with "CustomerID" and "PhoneNum" with "Phone" in the table.
Table.RenameColumns( Table.FromRecords({[CustomerNum = 1, Name = "Bob", PhoneNum = "123-4567"]}), { {"CustomerNum", "CustomerID"}, {"PhoneNum", "Phone"} } )
I have a list of lists in another query that I tried using in this function. However, I'm getting an error/the function is not accepting my list of lists.
I created two codes that you can use to replicate the data and all my steps, which you can paste directly into the advanced editor to create a new query.
Code for the list of lists:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WilHyz0nxS8xNNYxRUtIBcv1Sy2HcWB0keSNUeSN0eWNUeRA3NhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OldNames = _t, NewNames = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"OldNames", type text}, {"NewNames", type text}}),
#"merge old name and new name columns" = Table.CombineColumns(#"Changed Type",{"OldNames", "NewNames"},Combiner.CombineTextByDelimiter(",", QuoteStyle.None),"Old and New Names"),
#"create list of lists" = Table.ToRows(#"merge old name and new name columns")
in
#"create list of lists"
And here is a code which contains the table I am trying to apply the function to, and the failed result:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkksSTRU0gHTRlDaWCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OldName1 = _t, OldName2 = _t, OldName3 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"OldName1", type text}, {"OldName2", type text}, {"OldName3", type text}}),
#"run table rename columns function" = Table.RenameColumns(#"Changed Type", #"list of lists")
in
#"run table rename columns function"
When I run the Table.RenameColumns function, I get the error:
Expression.Error: We expected a RenameOperations value.
Details:
[List]
But #"list of lists" is a list, and should be formatted exactly like the list of lists used in the documentation example I provided, no?
I appreciate any help that can be provided...
Solved! Go to Solution.
Hi @Anonymous ,
just omit the merge step and you should be good to go:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WilHyz0nxS8xNNYxRUtIBcv1Sy2HcWB0keSNUeSN0eWNUeRA3NhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OldNames = _t, NewNames = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"OldNames", type text}, {"NewNames", type text}}),
#"create list of lists" = Table.ToRows(#"Changed Type")
in
#"create list of lists"
By merging the columns, you are creating one string that will then become a list with just one element.
But you need a list with 2 elements in it. So omitting the merge will just solve the issue.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @Anonymous ,
great!
So if this is solved, please mark my answer as solution. Thanks.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
I have already!:)
Hi @Anonymous ,
if you post the query code I can take a look at it.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi, I've discovered the problem, a null value was being loaded into the nested list, which was throwing me the error. I appreciate your help!
Hi @Anonymous ,
usually the quotation marks are added automatically once you reference column with the strings in it.
Can you please share more specifically what the actual basis for your operation looks like?
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @Anonymous ,
just omit the merge step and you should be good to go:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WilHyz0nxS8xNNYxRUtIBcv1Sy2HcWB0keSNUeSN0eWNUeRA3NhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [OldNames = _t, NewNames = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"OldNames", type text}, {"NewNames", type text}}),
#"create list of lists" = Table.ToRows(#"Changed Type")
in
#"create list of lists"
By merging the columns, you are creating one string that will then become a list with just one element.
But you need a list with 2 elements in it. So omitting the merge will just solve the issue.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi Imke --
The example I provided you worked after I made that adjustment in my query. But when I ran the same steps on my actual data, I am still getting the same error, even though I have a nested list:
Expression.Error: We expected a RenameOperations value.
Details:
[List]
For some reason, my query doesn't seem to recognize that the query with my nested list is a list.
ahh thank you! bonus question for you: do you know a quick way to wrap all strings in each cell in quotations? my actual dataset contains all the find and replace values but they are not wrapped in quotation marks, so they look like this: Oldval, Newval .. instead of this: "Oldval", "Newval"
oh I think I got confused and thought I needed to add quotation marks. I will test things out on my end.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
10 | |
8 | |
6 | |
6 | |
6 |