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
Anonymous
Not applicable

IF Statement, Switch statement - Direct Query

I am trying to make a new calculated column or measure (whichever is compatible) in my report. I am running into some issues however do to the data being accessed via Direct Query.

 

I was initially trying to create the following custom column: 

Success/Fail = IF(SEARCH("Canceled", 'tsd v_ChangeRequestTasks'[CRQ Success]),"FAIL",
                             IF(SEARCH("Failed", 'tsd v_ChangeRequestTasks'[CRQ Success]), "FAIL", "SUCCESS"))
 
but received the message: "Function 'SEARCH' is not allowed as part of calculated column DAX expressions on DirectQuery models."

 

If the measure [CRQ Success] contains the keyword “Canceled”, or “Failed”, I would like the new custom column to say “FAIL”. Otherwise I would like the new column to say “Success” . (See pic)

CRQ success.png

 

 

 

 

 

 

 

 

I believe this is a simple DAX statement, but I have been running into an error the way I have approached the issue because I am using Direct Query for this dataset.

 

Example Data:

CRQ Success

NEW COLUMN

Success, Success

Success

Canceled

FAIL

Success, Canceled

FAIL

Failed, Success

FAIL

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use CONTAINSSTRING function to meet your requirement.

We can create a measure like this,

 

We can create a measure like this,
Measure = 
IF(
    CONTAINSSTRING( MAX('Table'[CRQ Success]),"Canceled"),"FAIL",
    IF(
        CONTAINSSTRING(MAX('Table'[CRQ Success]),"Failed*"), "FAIL", "SUCCESS"))

 

IF1.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can use CONTAINSSTRING function to meet your requirement.

We can create a measure like this,

 

We can create a measure like this,
Measure = 
IF(
    CONTAINSSTRING( MAX('Table'[CRQ Success]),"Canceled"),"FAIL",
    IF(
        CONTAINSSTRING(MAX('Table'[CRQ Success]),"Failed*"), "FAIL", "SUCCESS"))

 

IF1.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Greg_Deckler
Community Champion
Community Champion

@Anonymous - You may have better luck with a measure versus a column.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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