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

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

Reply
Anonymous
Not applicable

Count of Rows, match part of text: using wildcards

I am trying to count the rows that contain a code, I need to match using wildcards:

 

The codes I need to count ares: X*S and IX*S, the actual codes in the data are XFS/XGS or IXFS/IXGS

 

This is my calculation: RESO= (CALCULATE(COUNTROWS('table1'), 'table1'[Code] = "X*S" ) + CALCULATE(COUNTROWS('table1'), 'table1'[Code] = "IX*S" ) 
 
The * and ? wildcard is not working
 
Any solution? Thanks in advance 
1 REPLY 1
Anonymous
Not applicable

DAX does not have regular expressions, nor does it have wildcards.

Create a column in Power Query (not in DAX!) and put 1 in a row if the code matches your pattern and 0 if not.

The rule is that the above column should come to your model from the data source. This should not be calculated in DAX by any means for many, many reasons. Easy as that.

Once you have this column, your measure is simple:

SUM( T[MatchesPattern] )

Best
Darek

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.