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
Syndicate_Admin
Administrator
Administrator

REPLACE CHARACTERS TO WHITE

Hello everyone good afternoon.

One question, how do I do to do the next operation, In a Phone Column there is some data that is only 4 characters or less, the idea is that data containing 4 or fewer characters will be replaced to Blank.

ColumnaTelefonos

12345678

1234567

1234

1

345

25

1188

123456

make it look like this.

ColumnaTelefonos

12345678

1234567

BLANK

BLANK

BLANK

BLANK

BLANCK

123456

Thank you for any help

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Syndicate_Admin 

It would be easy if you use Custom Column,

v-xiaotang_0-1619163226914.png

 

if Text.Length([ColumnaTelefonos]) <=4 then null else [ColumnaTelefonos]

 

If you don't need the original column, you can remove it

v-xiaotang_1-1619163226919.png

 

OR

If you want to solve it by advanced editor, you can take steps below for reference:

v-xiaotang_2-1619163226932.png

 

 let
    Source = Excel.Workbook(File.Contents("C:\Temp Testing Only\SampleData.xlsx"), null, true),
    Table_Sheet = Source{[Item="Table",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Table_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"ColumnaTelefonos", type text}}),
    #"Custom1" =Table.TransformColumns(#"Changed Type",{"ColumnaTelefonos", each if Text.Length(_) <= 4 then null else _,type text})
in
    Custom1

 

 then, you will get the following:

v-xiaotang_0-1619163582760.png

Hope it helps.

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @Syndicate_Admin 

It would be easy if you use Custom Column,

v-xiaotang_0-1619163226914.png

 

if Text.Length([ColumnaTelefonos]) <=4 then null else [ColumnaTelefonos]

 

If you don't need the original column, you can remove it

v-xiaotang_1-1619163226919.png

 

OR

If you want to solve it by advanced editor, you can take steps below for reference:

v-xiaotang_2-1619163226932.png

 

 let
    Source = Excel.Workbook(File.Contents("C:\Temp Testing Only\SampleData.xlsx"), null, true),
    Table_Sheet = Source{[Item="Table",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Table_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"ColumnaTelefonos", type text}}),
    #"Custom1" =Table.TransformColumns(#"Changed Type",{"ColumnaTelefonos", each if Text.Length(_) <= 4 then null else _,type text})
in
    Custom1

 

 then, you will get the following:

v-xiaotang_0-1619163582760.png

Hope it helps.

 

Best Regards,

Community Support Team _ Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Syndicate_Admin
Administrator
Administrator

Super funcion me a thousand thanks 😄

Syndicate_Admin
Administrator
Administrator

Hello, thank you for your response look I did what you tell me but I get a mistake.

I don't think I'm doing wrong.error.PNG

mahoneypat
Employee
Employee

You can do a custom transform on the column.  If that column is a number column, you can add a step after (hit the fx button to the left of the formula bar) and replace it (in the formula bar) with this.  Replace #"Filtered Rows" with the name of your previous step.

 

= Table.TransformColumns(#"Filtered Rows", {{"ColumnaTelefonos", each if _ <= 9999 then null else _, type number}})

 

If it is a text column, you can use this instead.

= Table.TransformColumns(#"Filtered Rows", {{"ColumnaTelefonos", each if Text.Length(_) <= 4 then null else _, type text}})

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.