Table.TransformColumnNames in nested table

ooptennoort

Board Regular
Joined
Mar 29, 2021
Messages
67
Office Version
  1. 365
Platform
  1. Windows
I need to replace ":" with "" in column names but in a nested table (that I cannot expand yet)... 2 problems:

1) How do I get a nested table as table (1st argument of Table.TransformColumnNames)
2) Then how do i actually get the column names' text replaced

I tried along these lines:

= Table.TransformColumnNames( Table.FromList(RemovedTopRowPromotedHeaders[Data], Splitter.SplitByNothing(), null, null, ExtraValues.Error), (_) as text => Text.Clean(Text.Replace(_,":","")))

= Table.AddColumn(Custom2, "RecordToList", each List.ReplaceValue(Record.ToList([Data]{1}),":","",Text.Replace))

even:
RecordsToList = Table.AddColumn(#"Removed Other Columns1", "RecordsToList", each Record.ToList([Data]{1})),
RenRecordsToList = Table.AddColumn(RecordsToList, "RenRecordsToList", each List.ReplaceValue([RecordsToList],":","", Replacer.ReplaceText)),
Custom2 = Table.RenameColumns([Data], [RecordsToList],[RenRecordsToList] ),
AddRemTopRowHeaderPromoted = Table.AddColumn(Custom2, "Ranges", each Table.PromoteHeaders( Table.Skip([Data],1))),
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
See if this works for you

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"1:00", type text}, {"2:00", type text}, {"3:00", type text}, {"4:00", type text}, {"5:00", type text}}),
    #"Demoted Headers" = Table.DemoteHeaders(#"Changed Type"),
    #"Transposed Table" = Table.Transpose(#"Demoted Headers"),
    #"Replaced Value" = Table.ReplaceValue(#"Transposed Table",":","",Replacer.ReplaceText,{"Column1"}),
    #"Transposed Table1" = Table.Transpose(#"Replaced Value"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table1", [PromoteAllScalars=true])
in
    #"Promoted Headers"

Book5
ABCDEFGHIJK
11:002:003:004:005:00100200300400500
2BBBBBBBBBB
3CCCCCCCCCC
4DDDDDDDDDD
5EEEEEEEEEE
6FFFFFFFFFF
7GGGGGGGGGG
8HHHHHHHHHH
9IIIIIIIIII
10JJJJJJJJJJ
11KKKKKKKKKK
Sheet1
Cell Formulas
RangeFormula
A2:E11A2=SUBSTITUTE(ADDRESS(1,ROW(),4),"1","")
 
Upvote 0
Solution
See if this works for you

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"1:00", type text}, {"2:00", type text}, {"3:00", type text}, {"4:00", type text}, {"5:00", type text}}),
    #"Demoted Headers" = Table.DemoteHeaders(#"Changed Type"),
    #"Transposed Table" = Table.Transpose(#"Demoted Headers"),
    #"Replaced Value" = Table.ReplaceValue(#"Transposed Table",":","",Replacer.ReplaceText,{"Column1"}),
    #"Transposed Table1" = Table.Transpose(#"Replaced Value"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table1", [PromoteAllScalars=true])
in
    #"Promoted Headers"

Book5
ABCDEFGHIJK
11:002:003:004:005:00100200300400500
2BBBBBBBBBB
3CCCCCCCCCC
4DDDDDDDDDD
5EEEEEEEEEE
6FFFFFFFFFF
7GGGGGGGGGG
8HHHHHHHHHH
9IIIIIIIIII
10JJJJJJJJJJ
11KKKKKKKKKK
Sheet1
Cell Formulas
RangeFormula
A2:E11A2=SUBSTITUTE(ADDRESS(1,ROW(),4),"1","")
Thank you! Very simple method indeed, along really different lines ;)
I will look into it to see how I can transpose in a nested table. Shouldn't be difficult. Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,596
Members
452,657
Latest member
giadungthienduyen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top