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
Anonymous
Not applicable

Remove rows based on multiple criteria

Hello

 

What is the syntax for Power Query to remove rows on specific criteria?

 

I want to remove rows where (Col1 contains "something" and (Col2 is zero or null))

 

Thanks!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Filter the data based on those.

https://docs.microsoft.com/en-us/power-query/filter-values

 

or create column and filter that

if Text.Contains([Col1], "something") and ([Col2] =0 or [col2] = null) then 1 else 0

 

use filter for column , on this new column

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@amitchandak  thanks but I need the syntax in that format, can you tell me please?

 

Table.SelectRows(#"1", each not Text.Contains(Col.....

Hi @Anonymous 

In this scenario, you need to create a column then filter table by it, finally remove it.

-

here is the entire body of code

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxMVNJRMlSK1YlWSkpKArKNwOyqqiog2wCJnVeakwPmQrQYILHhUsnJyUCuMZidmpoKZJuA2SkpKZgmAC2KBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([Column1],"aaa") and ([Column2]=0 or [Column2]=null) then 1 else 0),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Custom] = 0)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Custom"})
in
    #"Removed Columns"

 

the code remove rows where (Col1 contains "aaa" and (Col2 is zero or null)vxiaotang_0-1647409625952.png

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.

amitchandak
Super User
Super User

@Anonymous , Filter the data based on those.

https://docs.microsoft.com/en-us/power-query/filter-values

 

or create column and filter that

if Text.Contains([Col1], "something") and ([Col2] =0 or [col2] = null) then 1 else 0

 

use filter for column , on this new column

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

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