Forum Discussion
Till__
3 years agoHelper I
Renaming multiple Headers
Dear all, I have multiple Headers which contain an ID before some text occurs. For example like in the table below. EF-1.1.1) Text1 EF-1.1.2) Text 2 EF-2.1.1) Text 3 Is there ...
- 3 years ago
Okay, try this as a custom step instead:
Table.RenameColumns( previousStepName, List.Transform( Table.ColumnNames(previousStepName), each {_, if Text.StartsWith(_, "EF") then Text.BeforeDelimiter(_, ")") else _} ) )Working example query:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUUoC4mQgTgHiVKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"EF-1.1.1) Some text" = _t, #"EF-1.1.2) Some Words" = _t, #"EF-2.1.1) Some Writing" = _t, #"AB-1.1.1) Some Stuff" = _t, #"TT-1.1.1) Blah Blah" = _t]), Custom2 = Table.RenameColumns( Source, List.Transform( Table.ColumnNames(Source), each {_, if Text.StartsWith(_, "EF") then Text.BeforeDelimiter(_, ")") else _} ) ) in Custom2Example output:
Pete
Till__
3 years agoHelper I
Dear BA_Pete, I want to do this only for columns which include the name "EF-"
I was trying to do this with the following code but this did not work out... Do you have an idea?
= Table.TransformColumnNames(#"Erweiterte Tabellenspalte1", each Text.BeforeDelimiter(_, ")",List.Select(Table.ColumnNames(#"Erweiterte Tabellenspalte1"), each Text.Contains(_, "EF-"))))
BA_Pete
3 years agoSuper User
Okay, try this as a custom step instead:
Table.RenameColumns(
previousStepName,
List.Transform(
Table.ColumnNames(previousStepName),
each {_, if Text.StartsWith(_, "EF") then Text.BeforeDelimiter(_, ")") else _}
)
)
Working example query:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUUoC4mQgTgHiVKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"EF-1.1.1) Some text" = _t, #"EF-1.1.2) Some Words" = _t, #"EF-2.1.1) Some Writing" = _t, #"AB-1.1.1) Some Stuff" = _t, #"TT-1.1.1) Blah Blah" = _t]),
Custom2 =
Table.RenameColumns(
Source,
List.Transform(
Table.ColumnNames(Source),
each {_, if Text.StartsWith(_, "EF") then Text.BeforeDelimiter(_, ")") else _}
)
)
in
Custom2
Example output:
Pete