cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

DAX IF contains text wildcard

I'm trying to use a 'contains' rule in an IF statement but I keep getting an error. The statement needs to be nested within a longer IF statement too! 

 

In English, the part I'm struggling with should mean:

 

If FILENAME contains 'bounce', return 'bounce: accepted', otherwise return 'other'

2 ACCEPTED SOLUTIONS
ChrisMendoza
Super User
Super User

@Anonymous -

 

I found this interesting article https://www.sqlbi.com/articles/from-sql-to-dax-string-comparison/. Some good examples of use as well as performance.

 

This works in my small sample:

Column =
IF (
    SEARCH (
        "Bounce",
        Table1[Text],
        1,
        0
    ),
    "bounce-accepted",
    "others"
)





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

rocky09
Impactful Individual
Impactful Individual


@Anonymous wrote:

Didn't work, I'm afraid. It returned all 0 - oddly, if I tried just the search function, then I had the odd column returning 11?!

 

To double check, Table1[Text] should be the column in which I'm searching for 'bounce'? 

IF(SEARCH("bounce",Table1[Text],1,0) = 1,"bounce-Accepted","Others")

 Thank you for your help!!


Yes. Correct.

View solution in original post

6 REPLIES 6
acan12
New Member

I have an issue where, i have a coulmn below, and i want to get rid of hour and minutes from this column, i had tried many option, but nothing seems to work! can anyone help me on this?

 

acan12_0-1593598634124.png

 

v-cherch-msft
Microsoft
Microsoft

Hi @Anonymous 

Could you tell me if your problem has been solved? If it is,kindly mark the helpful answer as a solution if you feel that makes sense. 

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ChrisMendoza
Super User
Super User

@Anonymous -

 

I found this interesting article https://www.sqlbi.com/articles/from-sql-to-dax-string-comparison/. Some good examples of use as well as performance.

 

This works in my small sample:

Column =
IF (
    SEARCH (
        "Bounce",
        Table1[Text],
        1,
        0
    ),
    "bounce-accepted",
    "others"
)





Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



rocky09
Impactful Individual
Impactful Individual

Try this

 

Column = IF(SEARCH("bounce",Table1[Text],1,0) = 1,"bounce-Accepted","Others")
Anonymous
Not applicable

Didn't work, I'm afraid. It returned all 0 - oddly, if I tried just the search function, then I had the odd column returning 11?!

 

To double check, Table1[Text] should be the column in which I'm searching for 'bounce'? 

IF(SEARCH("bounce",Table1[Text],1,0) = 1,"bounce-Accepted","Others")

 Thank you for your help!!

rocky09
Impactful Individual
Impactful Individual


@Anonymous wrote:

Didn't work, I'm afraid. It returned all 0 - oddly, if I tried just the search function, then I had the odd column returning 11?!

 

To double check, Table1[Text] should be the column in which I'm searching for 'bounce'? 

IF(SEARCH("bounce",Table1[Text],1,0) = 1,"bounce-Accepted","Others")

 Thank you for your help!!


Yes. Correct.

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Top Solution Authors