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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vividarinda
Helper II
Helper II

SQL Like Filter

Hi Experts,

 I am novice to power bi and struggling with query in sql to convert in dax query.

For example : 

IH06.TPLNR_FUNCTIONALLOC NOT LIKE '16__9___'

 

How to convert query in dax query?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @vividarinda ,

You can create a calculated column as below to get it:

Category = 
    SWITCH(
        TRUE(),
        LEFT([UnitNo], 2) = "77", "KBL",
        LEFT([UnitNo], 2) = "16" && MID([UnitNo], 5, 1) = "9", "Rental",
        "PETROSEA"
    )

vyiruanmsft_0-1704169313354.png

Best Regards

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @vividarinda ,

I created  a sample pbix file(see the attachment), please check if that is what you want.

Table 2 = FILTER('Table',IFERROR(SEARCH("16__9___",'Table'[TPLNR_FUNCTIONALLOC],1,0),0)=0)

vyiruanmsft_0-1704098728187.png

Best Regards

Hi @Anonymous ,

Thanks your feedback, i mean, can i filter with escape underscore in dax query?

IH06.TPLNR_FUNCTIONALLOC NOT LIKE '16__9___'

Fowmy
Super User
Super User

@vividarinda 

DAX has a function called CONTAINSSTRING, it should work for you. 
Example:Countries ending with "land"

Evaluate
FILTER ( ALL ( Customer[CountryRegion] ), CONTAINSSTRING ( Customer[CountryRegion], "*land" ) )

 




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy  ,

Thanks your feedback, i mean, can i filter with escape underscore in dax query?

IH06.TPLNR_FUNCTIONALLOC NOT LIKE '16__9___'

Anonymous
Not applicable

Hi @vividarinda ,

Could you please provide some raw data and samples to explain your requirement?


 filter with escape underscore in dax query?

IH06.TPLNR_FUNCTIONALLOC NOT LIKE '16__9___'


Best Regards

I have a raw data like this,

 

UnitNoCategory
77DZ0279KBL
77DZ0249KBL
77GD9006KBL
77GD0062KBL
16DZ0277PETROSEA
16EX0154PETROSEA
16EX9011Rental
16DZ9178Rental

 

then i want filter based on condition like this :

- If UnitNo start with 77, then "KBL",
- If UnitNo start with 16__9___, then "Rental",
- If else "Petrosea"

Anonymous
Not applicable

Hi @vividarinda ,

You can create a calculated column as below to get it:

Category = 
    SWITCH(
        TRUE(),
        LEFT([UnitNo], 2) = "77", "KBL",
        LEFT([UnitNo], 2) = "16" && MID([UnitNo], 5, 1) = "9", "Rental",
        "PETROSEA"
    )

vyiruanmsft_0-1704169313354.png

Best Regards

Thank you very much for your help very helpful 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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