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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
gio1082
Helper I
Helper I

clean data

Hi, 

I have a data that I want to clean. I want to remove data from a row if its has "DOC" (ex 10265049DOC), and if less then 7 chracters (Ex: 12MM,4, 123m33) but keep anything data that  starts with an S  (S0644, S000012, S012)

 

thank you

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@gio1082 

In Power Query, Add the below code as new Custom Column then filter by FALSE, you get as per your requirement.

 = if  Text.Start([DATA],1) = "S" then false else Text.Contains([DATA],"DOC") or Text.Length([DATA]) < 7



________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
mahoneypat
Microsoft Employee
Microsoft Employee

Just to clarify.  Are each of the values on separate rows?  Or are you trying to keep just parts of longer strings on each row?  If the former, does this approach work

 

1. Turn on the Formula Bar on the view tab (check the box)

 

2. Select the column with text values and, on the Transform tab, do a Format step (add prefix, lowercase, etc.).  It doesn't matter which one, as you are just using this to generate most of the code you'll need.  You'll get a step added like this

 

= Table.TransformColumns(#"Changed Type",{{"TextColumn", Text.Lower, type text}})

 

3. Replace the Text.Lower part (or whatever function you chose) with the code shown below

 

= Table.TransformColumns(#"Changed Type",{{"TextColumn", each if Text.StartsWith(_, "S") then _ else null}})

 

This will keep only the values that start with "S" and replace the rest with null.  You can added the expression as needed to get your desired logic.  "_" just refers to the value in that column on that row.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

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


Fowmy
Super User
Super User

@gio1082 

In Power Query, Add the below code as new Custom Column then filter by FALSE, you get as per your requirement.

 = if  Text.Start([DATA],1) = "S" then false else Text.Contains([DATA],"DOC") or Text.Length([DATA]) < 7



________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors