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

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

Reply
Anonymous
Not applicable

Wildcards with IF in DAX

Hello All,

 

I have a table like this in Excel where column "B" is bringing "TRA" everytime it finds that word within the codes in column "A"... no matter where "TRA" is positioned in the word.

For doing so, i'm using ISNUMBER + SEARCH formulas and works like a charm. Can you guys please help me replicate this in DAX??

 

This is the formula in cell B2: =IF(ISNUMBER(SEARCH($B$1;A2));"TRA";"")

 

edsonlf_1-1597965164224.png

 

Thanks!

Edson

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

You can do it in many ways.

 

Some listed

 

Incase of M create a Conditional Column

 

2.JPG

 

 

In DAX you can create a new Column

 

DAX COLUMN 1 =
IF (
    SEARCH (
        "TRA",
        'Table'[String],
        1,
        0
    ) > 0,
    "TRA",
    BLANK ()
)

 

 

DAX Column = IF (CONTAINSSTRING('Table'[String], "TRA"), "TRA" ,BLANK())

 

 

1.jpg

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

I would do it in Power Query. First, it's the tool designed for this kind of manipulation. Second, processing be faster. Third, you'll get the best compression and hence fastest DAX. If the table you want to do it on is BIG, Power Query is your only option (unless you can push the calc to your source system).
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

You can do it in many ways.

 

Some listed

 

Incase of M create a Conditional Column

 

2.JPG

 

 

In DAX you can create a new Column

 

DAX COLUMN 1 =
IF (
    SEARCH (
        "TRA",
        'Table'[String],
        1,
        0
    ) > 0,
    "TRA",
    BLANK ()
)

 

 

DAX Column = IF (CONTAINSSTRING('Table'[String], "TRA"), "TRA" ,BLANK())

 

 

1.jpg

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

amitchandak
Super User
Super User

@Anonymous , You can create a new column

if(CONTAINSSTRING([codes], "TRA") ,"TRA",blank())

 

https://docs.microsoft.com/en-us/dax/containsstring-function-dax

 

Other is

https://docs.microsoft.com/en-us/dax/search-function-dax

https://docs.microsoft.com/en-us/dax/find-function-dax

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
lbendlin
Super User
Super User

Same thing in DAX . Use FIND()  (case sensitive) or SEARCH() (not case sensitive) and handle the result the same way.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.