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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

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
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.