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
christianunr
Frequent Visitor

How to Remove Entire Values Based on Condition?

I have a column like so:

Cost Center
CC0328:

PG12312

PG12333

PG09862
PG12312
CC0223:
PG23423
PG76732
PG92332

I'm looking to remove all the values that start with "PG" so that I am only left with values that start with "CC".

I've tried the following code but it's not working as expected:

 

 

= Table.ReplaceValue(#"Renamed Columns",
each "Cost Center",
each if Text.Start("PG") then "" else false,
Replacer.ReplaceText,{"Cost Center"})

 

 

How can I properly remove all values that start with "PG"?

Thank you.

 

1 ACCEPTED SOLUTION

Ah, OK. Add a new conditional column

 = Table.AddColumn(#"Changed Type", "Custom", each if Text.StartsWith([Cost Center], "PG") then null else [Cost Center])

then you can delete the original column and rename the new one to Cost Center

View solution in original post

3 REPLIES 3
johnt75
Super User
Super User

Click the down arrow in the header of the column you want to filter and choose Text Filters -> Starts With, or Does not start with

That removes the entire row from the table when I'm in the data tab. I still need to keep the rows.

Ah, OK. Add a new conditional column

 = Table.AddColumn(#"Changed Type", "Custom", each if Text.StartsWith([Cost Center], "PG") then null else [Cost Center])

then you can delete the original column and rename the new one to Cost Center

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.