Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
monojchakrab
Resolver III
Resolver III

Rename nested tables

Hey good people of Power query,

 

I have a table with a column holding nested tables as below :

 

monojchakrab_0-1689074152654.png

What I am trying to achieve is as follows :

  • If the [Account] = "Flipkart", rename two columns for the corresponding table in the [Data] column, else
  • leave the original table unchanged

Towards this, I have written the following code :

 

= Table.TransformColumns(RemovePharmEasy,{{"Data",if [Account]="Flipkart"
        then each Table.RenameColumns([Data],{{"Product Title/Description","Product Title"},{"Item Quantity","Item Qty"}}) 
else _}})

 

But unfortunately its returning an error as below :

 

Screenshot (147).png

Am I missing something? 

 

Any help much appreciated.

 

best regds.,

2 ACCEPTED SOLUTIONS
BA_Pete
Super User
Super User

Hi @monojchakrab ,

 

You can do it fairly easily if you add your updated tables as a new column:

 

addNewDataTables = 
    Table.AddColumn(
        previousStep,
        "newData",
        each let __account = [Account] in
        if __account = "Flipkart"
        then Table.RenameColumns(
            [Data],
            {
                {"Product Title/Description", "Product Title"},
                {"Item Quantity", "Item Qty"}
            }
        )
        else [Data]
    )

 

Which gives the following outputs:

 

Non-Flipkart:

BA_Pete_0-1689087092037.png

 

Flipkart:

BA_Pete_1-1689087118507.png

 

Full example queries:

// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsxNrMrPU4rViVZyy8ksyE4sKgFzvDLzfWFshEQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Account = _t]),
    addData = Table.AddColumn(Source, "Data", each Table2),

    addNewDataTables = 
        Table.AddColumn(
            addData,
            "newData",
            each let __account = [Account] in
            if __account = "Flipkart"
            then Table.RenameColumns(
				[Data],
                {
					{"Product Title/Description", "Product Title"},
					{"Item Quantity", "Item Qty"}
				}
			)
			else [Data]
		)
in
    addNewDataTables

// Table2
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs5Pzi5W0lEys1SK1YlWCkjMKwFxTYwMlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Product Title/Description" = _t, #"Item Quantity" = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"Product Title/Description", type text}, {"Item Quantity", Int64.Type}})
in
    chgTypes

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

latimeria
Solution Specialist
Solution Specialist

Hi @monojchakrab ,

I would tackle the problem like this:

  • split the table RemovePharmEasy , account = flipkart and the other one account not = flikart
  • do your tranformation on the flipkart
  • merge back the 2 table
splitflipkart = Table.SelectRows(flipkart, each ([Account] = "flipchart"))
splitothers = Table.SelectRows(flipkart, each not ([Account] = "flipchart"))
transform= Table.TransformColumns(splitflipkart,  ....)
merge = Table.Combine(transform, splitaothers)

 

View solution in original post

2 REPLIES 2
latimeria
Solution Specialist
Solution Specialist

Hi @monojchakrab ,

I would tackle the problem like this:

  • split the table RemovePharmEasy , account = flipkart and the other one account not = flikart
  • do your tranformation on the flipkart
  • merge back the 2 table
splitflipkart = Table.SelectRows(flipkart, each ([Account] = "flipchart"))
splitothers = Table.SelectRows(flipkart, each not ([Account] = "flipchart"))
transform= Table.TransformColumns(splitflipkart,  ....)
merge = Table.Combine(transform, splitaothers)

 

BA_Pete
Super User
Super User

Hi @monojchakrab ,

 

You can do it fairly easily if you add your updated tables as a new column:

 

addNewDataTables = 
    Table.AddColumn(
        previousStep,
        "newData",
        each let __account = [Account] in
        if __account = "Flipkart"
        then Table.RenameColumns(
            [Data],
            {
                {"Product Title/Description", "Product Title"},
                {"Item Quantity", "Item Qty"}
            }
        )
        else [Data]
    )

 

Which gives the following outputs:

 

Non-Flipkart:

BA_Pete_0-1689087092037.png

 

Flipkart:

BA_Pete_1-1689087118507.png

 

Full example queries:

// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcsxNrMrPU4rViVZyy8ksyE4sKgFzvDLzfWFshEQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Account = _t]),
    addData = Table.AddColumn(Source, "Data", each Table2),

    addNewDataTables = 
        Table.AddColumn(
            addData,
            "newData",
            each let __account = [Account] in
            if __account = "Flipkart"
            then Table.RenameColumns(
				[Data],
                {
					{"Product Title/Description", "Product Title"},
					{"Item Quantity", "Item Qty"}
				}
			)
			else [Data]
		)
in
    addNewDataTables

// Table2
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCs5Pzi5W0lEys1SK1YlWCkjMKwFxTYwMlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Product Title/Description" = _t, #"Item Quantity" = _t]),
    chgTypes = Table.TransformColumnTypes(Source,{{"Product Title/Description", type text}, {"Item Quantity", Int64.Type}})
in
    chgTypes

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.