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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
winterbloom
Frequent Visitor

Remove values from cell containing specific character

Hi all,

 

I have got a large table with many columns. One of these columns contain some values that I need, some nulls and some with values I need to remove.

 

Here is a snippet of the column in BI data view:

winterbloom_0-1687404785913.png

 

I want to keep the values shown in the background. Meanwhile there are thousands of rows where the values in this column is gibberish. I need these values to be blank/nulls instead.

 

One option is to replace all values where the special character "²" occurs. Another option would be to remove values where the string exceeds 10 characters.

 

How can I do this in Power Query?

TIA

2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @winterbloom 

 

Download example PBIX file

 

Just re-read your question and think I have misunderstood what you want.

 

If you want to keep all the rows and just remove the values with a ² in them, or that are more than 10 characters, add a Custom Column with this code

 

 = if Text.Contains([Value], "²") or Text.Length([Value]) > 10 then null else [Value]

 

 

dnqs.png

 

Then delete the original column.

 

I'll leave my initial reply as an FYI.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

ronrsnfld
Super User
Super User

In the PQ Advanced Editor, add a step that transforms the contents of cells in that column to null if they contain "²" or have more than ten characters.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNlGK1YlWMjUztwAzQCKHNpmawTkgGUtDiMJYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),

//Transform cells that contain more than 10 characters, or contain ²  to null
    #"Transform garbage" = Table.TransformColumns(#"Changed Type",{"Column1", 
        each if Text.Length(_)>10 or Text.Contains(_,"²") then null else _})
in
    #"Transform garbage"

ronrsnfld_0-1687484219140.png

becomes:

ronrsnfld_1-1687484262448.png

 

 

 

View solution in original post

3 REPLIES 3
ronrsnfld
Super User
Super User

In the PQ Advanced Editor, add a step that transforms the contents of cells in that column to null if they contain "²" or have more than ten characters.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNlGK1YlWMjUztwAzQCKHNpmawTkgGUtDiMJYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),

//Transform cells that contain more than 10 characters, or contain ²  to null
    #"Transform garbage" = Table.TransformColumns(#"Changed Type",{"Column1", 
        each if Text.Length(_)>10 or Text.Contains(_,"²") then null else _})
in
    #"Transform garbage"

ronrsnfld_0-1687484219140.png

becomes:

ronrsnfld_1-1687484262448.png

 

 

 

PhilipTreacy
Super User
Super User

Hi @winterbloom 

 

Download example PBIX file

 

Just re-read your question and think I have misunderstood what you want.

 

If you want to keep all the rows and just remove the values with a ² in them, or that are more than 10 characters, add a Custom Column with this code

 

 = if Text.Contains([Value], "²") or Text.Length([Value]) > 10 then null else [Value]

 

 

dnqs.png

 

Then delete the original column.

 

I'll leave my initial reply as an FYI.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @winterbloom 

 

This query filters out any row that has the ² character in it

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNlGK1YlWMjUztwAzDAxB8NAmI3MzI2OopAEIGBmYAEUNTZGEDA0ObQKShgZgIZBZEGNiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
    #"Filtered Rows" = Table.SelectRows(Source, each not Text.Contains([Value], "²"))
in
    #"Filtered Rows"

 

 

To implement this, click on the Drop Down Arrow in the column header, then click Text Filters -> Does Not Contain

 

dnq3.png

 

 

and enter this

 

dnq2.png

 

Regards

 

Phil

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.