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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Jeffrey2
Helper I
Helper I

"Does Not Contain" is picking up null values

I have a power query table that I have narrowed down to two records, one the original and one that is close to being a duplicate (the Comments column).

 

In record one, the Comments field is null. In record two, the field says "Duplicate Initiation". 

 

I added a step that says Table.SelectRows(#"Filtered Rows1", each not Text.Contains([Comments], "Duplicate")).

 

However, it's removing both records instead of just keeping the record with the null in comments. How do I keep the record with the null value and remove the record with the "Duplicate" word. 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Jeffrey2 ,

 

Try this instead:

Table.SelectRows(#"Filtered Rows1", each not Text.Contains([Comments], "Duplicate") or [Comments] = null)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

8 REPLIES 8
mussaenda
Super User
Super User

Hi @Jeffrey2 ,

 

Can you try to exclude the null on your filter like below?

Table.SelectRows(#"Filtered Rows1", each not Text.Contains([Comments], "Duplicate") and [Comments] <> null)

 

Hope this helps.

BA_Pete
Super User
Super User

Hi @Jeffrey2 ,

 

Try this instead:

Table.SelectRows(#"Filtered Rows1", each not Text.Contains([Comments], "Duplicate") or [Comments] = null)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thanks @BA_Pete . The logic doesn't really make sense to me, but it fixed the problem. 

 

You're giving the the SelectRows function a choice: either give me something that doesn't contain "Duplicate", or give me a null.

However, this is a very narrow example-case, so the logic may fall over with a broader sampleset.

For example, what happens when you have rows that otherwise match, but one has "Whatever" in [comments], and the other has null. Both of these rows will be retained using this logic - is this what you want/need?

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




I just want to get rid of rows that have the word "Duplicate" in the Comments field. Keep all other rows. If the row had "a;dlkfja;lkdfj;ladkjf;alkjfd;lakfj" I want to keep it. If a row had "adsf;lkaj;lsfkja;lkjfadsf Duplicate" , I want it removed. If a row had null, I want to keep it. 

 

I just think Table.SelectRows(#"Filtered Rows1", each not Text.Contains([Comments], "Duplicate")) should have been enough. To me this is a program error. 

 

@BA_Pete to use your wording, 

 

Table.SelectRows(#"Filtered Rows1", each not Text.Contains([Comments], "Duplicate")) should mean:

SelectRows function: give me something that doesn't contain "Duplicate".

 

If the comment only contains null, then it doesn't contain "Duplicate". Therefore it should be kept.

 

Ah, yes, I see what you mean.

However, a null doesn't contain any text either, so Text.Contains can't resolve to true or false.

As there's no text to evaluate, it has to resolve to null.

 

For example:

BA_Pete_0-1651847241922.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Thank you for the explanation. That makes total sense. 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.