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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
mdor
Frequent Visitor

SQL NOT LIKE in M language

Hello,

I have an SQL query that contains the NOT LIKE function. I have googled for an hour and didn't find a good solution. Can anyone help me with this task? Here is my SQL query:

 

SELECT
  *
FROM Product
Where  Description NOT LIKE '' and Product NOT LIKE 'CMI' 

 

Thanks in advance 

1 ACCEPTED SOLUTION
edhans
Community Champion
Community Champion

In Power Query, it would be:

Table.SelectRows(TableName, each not Text.StartsWith([Description], "") and not Text.StartsWith([Product], "CMI"))


Power Query doesn't have a LIKE operator. You'd use Text.Contains, Text.StartsWith, or Text.EndsWith depending on what you are trying to do. It does have a NOT operator, which is simply not - all lower case. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
edhans
Community Champion
Community Champion

In Power Query, it would be:

Table.SelectRows(TableName, each not Text.StartsWith([Description], "") and not Text.StartsWith([Product], "CMI"))


Power Query doesn't have a LIKE operator. You'd use Text.Contains, Text.StartsWith, or Text.EndsWith depending on what you are trying to do. It does have a NOT operator, which is simply not - all lower case. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
PhilipTreacy
Super User
Super User

Hi @mdor 

 

I'm not sure what your question is?  That is a valid SQL statement although you may be looking to amend the the 2nd part to 

 

 

and Product NOT LIKE '%CMI%' 

 

 

That said, if you write your own query like this you will break query folding and PQ will do all the hard work instead of the SQL database.

 

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

 

You would be better off loading the table into PQ then filtering out the data you want within PQ and then letting it tell the SQL database what data to send.

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


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.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

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.