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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bhanu_gautam
Super User
Super User

Replacing underscore with Space

Hi All,

 

I have a dataset with 50 columns and in column headers each column contains underscore and I want to remove all the underscore with space is there a way to do that

 

Current ScenarioTo Be
Account_NameYear_moSales_typeRegistration_noAccount NameYear moSales typeRegistration no

 

This is the current scenario and I want the  output to be like To Be columns name





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




2 ACCEPTED SOLUTIONS
v-cgao-msft
Community Support
Community Support

Hi @bhanu_gautam ,

Please try select these columns and unpivot them --> replace "_" with " " and pivot columns.

vcgaomsft_0-1706846509666.png

vcgaomsft_1-1706846525274.png

vcgaomsft_2-1706846547640.png
Advanced editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRU0lEyMgISxvHGQNIEiE2B2EwpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column_1 = _t, Column_2 = _t, Column_3 = _t, #"Column 4" = _t, Column_5_1 = _t, Column_5_2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column_1", Int64.Type}, {"Column_2", Int64.Type}, {"Column_3", type text}, {"Column 4", Int64.Type}, {"Column_5_1", Int64.Type}, {"Column_5_2", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Columns","_"," ",Replacer.ReplaceText,{"Attribute"}),
    #"Pivoted Column" = Table.Pivot(#"Replaced Value", List.Distinct(#"Replaced Value"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

slorin
Super User
Super User

Hi,

 

= Table.TransformColumnNames(Your_Source, each Text.Replace(_,"_"," "))

 Stéphane

View solution in original post

2 REPLIES 2
slorin
Super User
Super User

Hi,

 

= Table.TransformColumnNames(Your_Source, each Text.Replace(_,"_"," "))

 Stéphane

v-cgao-msft
Community Support
Community Support

Hi @bhanu_gautam ,

Please try select these columns and unpivot them --> replace "_" with " " and pivot columns.

vcgaomsft_0-1706846509666.png

vcgaomsft_1-1706846525274.png

vcgaomsft_2-1706846547640.png
Advanced editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRU0lEyMgISxvHGQNIEiE2B2EwpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column_1 = _t, Column_2 = _t, Column_3 = _t, #"Column 4" = _t, Column_5_1 = _t, Column_5_2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column_1", Int64.Type}, {"Column_2", Int64.Type}, {"Column_3", type text}, {"Column 4", Int64.Type}, {"Column_5_1", Int64.Type}, {"Column_5_2", Int64.Type}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value"),
    #"Replaced Value" = Table.ReplaceValue(#"Unpivoted Columns","_"," ",Replacer.ReplaceText,{"Attribute"}),
    #"Pivoted Column" = Table.Pivot(#"Replaced Value", List.Distinct(#"Replaced Value"[Attribute]), "Attribute", "Value")
in
    #"Pivoted Column"

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors