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
SJHALANI
Helper I
Helper I

Remove rows based on condition

Hi,

I have a table where I want to remove rows based on a given value in a column. For e.g., from the below table, I want to retain only the rows where Col D says "TBD". Hence, would want to retain rows 3 & 5 only and delete the rest. How can this be done using Power query? Any help would be appreciated. Thanks! 

Col ACol BCol CCol D
aadatadata123
bbdatadata321
ccdatadataTBD
dddatadata456
eedatadataTBD
1 REPLY 1
KeyurPatel14
Resolver IV
Resolver IV

Hi @SJHALANI ,
Hope you are doing well.
Please paste the below M Code in your Advanced Editor:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7PUXBU0gHTTlDaGUq7KMXqRCslJgK5KYklSJShkTFYKikJQ8rYyBAslZyMIRXiBDEwJQVDysTUDCyVmopdVywA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Col A", type text}, {"Col B", type text}, {"Col C", type text}, {"Col D", type text}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type1", each Text.Contains([Col D], "TBD"))
in
#"Filtered Rows"

If this helps then please give it a kudos and mark it as a solution.
Thank you.

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.

Top Solution Authors
Top Kudoed Authors