cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Replacing certain items within a column

Hello,

 

I'm currently doing some data cleaning but I stumbled into a problem. I have a column filled with names such as John, Willem, etc. But within that same column, I also have data in the form of E40 or N804. The items starting with E or N followed by a number should be replaced by null so I can fill down the names. 

 

Is there an easy way to accomplish this?

Thank you in advance! 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Replacing certain items within a column

Hi @Jenolski ,

 

Try this code:

let _value = [Column1] in
if
(
Text.Start([Column1], 1) = "E" or
Text.Start([Column1], 1) = "N"
) and List.Count(List.Select({"0".."9"},
each (_) = Text.Range(_value, 1,1))) > 0 then null
else [Column1]

 

Capture.PNG


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

View solution in original post

4 REPLIES 4
Highlighted
New Member

Re: Replacing certain items within a column

Additionally, E and N can be followed by different numbers. So not only the examples that I earlier gave. 

Highlighted
Super User IV
Super User IV

Re: Replacing certain items within a column

Well, we will need to find something that uniquely identifies those rows. Perhaps the presence of a comma (,)?


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




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

Proud to be a Super User!




Highlighted
Community Champion
Community Champion

Re: Replacing certain items within a column

Hi @Jenolski ,

 

Try this code:

let _value = [Column1] in
if
(
Text.Start([Column1], 1) = "E" or
Text.Start([Column1], 1) = "N"
) and List.Count(List.Select({"0".."9"},
each (_) = Text.Range(_value, 1,1))) > 0 then null
else [Column1]

 

Capture.PNG


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

View solution in original post

Highlighted
New Member

Re: Replacing certain items within a column

Works like a charm, thank you! 

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors