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
mstefancik
Advocate IV
Advocate IV

DAX equivalent of SQL LIKE

Hello, could anybody help me with DAX measure.

 

Lets say I have one Table with two columns:

 

TABLE: ID, Text

 

I would like to count allrows which includes certain string in Text field. String can be anywhere in the row not only at the beginning so in SQL %text_string%.

 

Is there any simple way to achieve aforedescribed?

 

Thanks

1 ACCEPTED SOLUTION
SamLester
Microsoft Employee
Microsoft Employee

The SEARCH function allows you to search for a specific string within another string. You can use a combination of CALCULATETABLE, DISTINCTCOUNT, and the SEARCH function, to count the number of occurrences:

 

 

CntRows = CALCULATETABLE(ROW("rows",DISTINCTCOUNT(Table1[Text])),FILTER(ALL(Table1[Text]),SEARCH("text_string",Table1[Text],1,0)))

 

 

There are more similar examples here:

http://sqlblog.com/blogs/marco_russo/archive/2011/12/30/string-comparison-in-dax.aspx

 

Thanks,
Sam Lester (MSFT)

View solution in original post

2 REPLIES 2
SamLester
Microsoft Employee
Microsoft Employee

The SEARCH function allows you to search for a specific string within another string. You can use a combination of CALCULATETABLE, DISTINCTCOUNT, and the SEARCH function, to count the number of occurrences:

 

 

CntRows = CALCULATETABLE(ROW("rows",DISTINCTCOUNT(Table1[Text])),FILTER(ALL(Table1[Text]),SEARCH("text_string",Table1[Text],1,0)))

 

 

There are more similar examples here:

http://sqlblog.com/blogs/marco_russo/archive/2011/12/30/string-comparison-in-dax.aspx

 

Thanks,
Sam Lester (MSFT)

marcorusso
Most Valuable Professional
Most Valuable Professional

The link in this thread no longer works - please use the following one instead - thanks!
https://www.sqlbi.com/blog/marco/2011/12/30/string-comparison-in-dax/

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors