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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
GarrettU
New Member

Changes to duplicated columns also affect the original column

When I run the code below, it affects both the original column and the duplicated column. How do I make this not happen? I want the original column to stay unaffected.

 

 

let
    Source = Csv.Document(File.Contents("...\Top15MCRLs.txt"),[Delimiter=",", Columns=15, Encoding=1252, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Filtered Rows" = Table.SelectRows(#"Promoted Headers", each ([RNCC] = "2" or [RNCC] = "3" or [RNCC] = "5") and ([RNVC] = "2")),
    #"Duplicated Column" = Table.DuplicateColumn(#"Filtered Rows", "Part_No", "Part_No - Copy"),
    #"Renamed Columns" = Table.RenameColumns(#"Duplicated Column",{{"Part_No - Copy", "Strip"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"RNSC", "RNAAC", "SADC", "DAC", "HCC", "MSDSID", "RNFC", "RNJC"}),
    #"Trimmed Text" = Table.TransformColumns(#"Removed Columns",{{"Strip", Text.Trim, type text}}),
    #"Cleaned Text" = Table.TransformColumns(#"Trimmed Text",{{"Strip", Text.Clean, type text}}),
    #"Uppercased Text" = Table.TransformColumns(#"Cleaned Text",{{"Strip", Text.Upper, type text}}),
    #"Strip" = Table.SelectRows(  #"Uppercased Text", each [Strip] = Text.Select([Strip],{"a".."z","A".."Z","0".."9"} ) )
in
    #"Strip"

 

(originally posted here: https://community.powerbi.com/t5/Desktop/How-to-remove-all-characters-except-alpha-numeric-in-text-c...

1 ACCEPTED SOLUTION

    #"Strip" = Table.SelectRows(  #"Uppercased Text", each [Strip] = Text.Select([Strip],{"a".."z","A".."Z","0".."9"} ) )

 

If this is the line that's causing it, what it actually does is select all rows where the value of [Strip] is equal to the value of [Strip]  that contains just alphanumeric characters.  If you want to cleaim it up by removing non-alphanumeric characters, the function to use is Table.TransformColumns

 

Strip = Table.TransformColumns( #"Uppercased Text",{{"Column1", each let x = {"a".."z", "A".."Z", "0".."9"} in Text.Select(_, x ), type text}} )




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
danextian
Super User
Super User

Hi @GarrettU,

 

In what way does your code affect the original and duplicated column? Does that happen in this step?

 

 #"Strip" = Table.SelectRows(  #"Uppercased Text", each [Strip] = Text.Select([Strip],{"a".."z","A".."Z","0".."9"} ) )

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Yes, both columns have alphanumeric characters removed even though I am calling column "strip"

    #"Strip" = Table.SelectRows(  #"Uppercased Text", each [Strip] = Text.Select([Strip],{"a".."z","A".."Z","0".."9"} ) )

 

If this is the line that's causing it, what it actually does is select all rows where the value of [Strip] is equal to the value of [Strip]  that contains just alphanumeric characters.  If you want to cleaim it up by removing non-alphanumeric characters, the function to use is Table.TransformColumns

 

Strip = Table.TransformColumns( #"Uppercased Text",{{"Column1", each let x = {"a".."z", "A".."Z", "0".."9"} in Text.Select(_, x ), type text}} )




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

This worked flawlessly, thanks! The only place I found this solution was this post. 🙂 

Thank you, works!

GarrettU
New Member

I was able to get it to work in a rather convoluted way by finding all existing ascii characters and removing them when adding a custom column. But I'd rather do it the way explained in the linked post. Here is the code:

Text.Combine(List.RemoveItems(Text.ToList([Part_No]),Text.ToList("{|}~ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø×ƒ""áíóúñѪº¿®¬½¼¡«»░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐└┴┬├─┼ãÃ╚╔╩╦╠═╬¤ðÐÊËÈıÍÎÏ┘┌█▄¦Ì▀ÓßÔÒõÕµþÞÚÛÙýݱ§÷¸°¨·¹³²■#$%&'()*+,-./:;<=>?@[\]^_ ")))

So I'd appreciate the help still!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors