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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
adoalan
Helper III
Helper III

Help with DAX Formula please

I have this piece of SQL code and I need to convert it in a DAX formula. 

adoalan_0-1669297971811.png

I got half way through it and the below is working perfectly:

TESTAGAIN =
SWITCH(
    TRUE(),
    ISBLANK('nfp_giftaiddeclaration'[Forename]), "Yes",
    ISBLANK('nfp_giftaiddeclaration'[Surname]), "Yes",
    ISBLANK('nfp_giftaiddeclaration'[House]), "Yes",
    ISBLANK('nfp_giftaiddeclaration'[Postcode]), "Yes",
    "No")
 
How ever I can't incorporate the last part with 
IF(CONTAINSSTRING( nfp_giftaiddeclaration[Forename] , "&" ) || CONTAINSSTRING(nfp_giftaiddeclaration[Surname], "&" ), "Y", "N")
 
Somehow I m missing something here and I can't get it done. I get this error:
adoalan_0-1669298190649.png

 

 
Can you help?
 
Many thanks 
 
9 REPLIES 9
NikhilChenna
Skilled Sharer
Skilled Sharer

Hi @adoalan ,

Please use the below i took it from your piece of example only,

 

TESTAGAIN =
SWITCH(
    TRUE(),
    ISBLANK('nfp_giftaiddeclaration'[Forename]), "Yes",
    ISBLANK('nfp_giftaiddeclaration'[Surname]), "Yes",
    ISBLANK('nfp_giftaiddeclaration'[House]), "Yes",
    ISBLANK('nfp_giftaiddeclaration'[Postcode]), "Yes",
    CONTAINSSTRING( nfp_giftaiddeclaration[Forename] , "&" ) || CONTAINSSTRING(nfp_giftaiddeclaration[Surname], "&" ), "Yes""No")
 
Check if this solves the issue.
 
Regards,
Nikhil Chenna
 
Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

@NikhilChenna it doesn't work

Hi @adoalan ,

 

Try this out then using IF condition 

 
    IF( 
    ISBLANK('nfp_giftaiddeclaration'[Forename]) || 
    ISBLANK('nfp_giftaiddeclaration'[Surname]) ||
    ISBLANK('nfp_giftaiddeclaration'[House]) ||
    ISBLANK('nfp_giftaiddeclaration'[Postcode]) ||
    CONTAINSSTRING( nfp_giftaiddeclaration[Forename] , "&" ) || 
    CONTAINSSTRING(nfp_giftaiddeclaration[Surname], "&" ), "Yes"
"No")
 
OR 
 
    IF( 
    'nfp_giftaiddeclaration'[Forename]=BLANK() || 
    'nfp_giftaiddeclaration'[Surname]=BLANK() ||
    'nfp_giftaiddeclaration'[House]=BLANK() ||
    'nfp_giftaiddeclaration'[Postcode]=BLANK() ||
    CONTAINSSTRING( nfp_giftaiddeclaration[Forename] , "&" ) || 
    CONTAINSSTRING(nfp_giftaiddeclaration[Surname], "&" ), "Yes"
"No")
This should work buddy.
 
Regards,
Nikhil Chenna
 

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

I created coloumn and getting this 

adoalan_0-1669303453745.png

 

Hi @adoalan , 

 

I have replicated the same with a sample table with 3 rows,

 

Please see you can access the attached one drive link.

IF condition 

 

I created this table - 

NikhilChenna_0-1669350907890.png

and using this calcution - 

 

Column =
IF(
'Table'[Forename]=BLANK() ||
'Table'[Surname]=BLANK() ||
'Table'[House]=BLANK() ||
'Table'[Postcode]=BLANK() ||
CONTAINSSTRING('Table'[Forename],"&") ||
CONTAINSSTRING('Table'[Surname],"&"),"Yes",
"No")
 
You can use this formula directly you just have to replace the table name.
 
Regards,
Nikhil Chenna
 
Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

 

 

 

Still not @NikhilChenna 

adoalan_0-1669300656751.png

 

Hi @adoalan ,

I think you are creating a calculated measure.

Create a calculated column.

 

Regards,

Nikhil Chenna

 

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

Greg_Deckler
Community Champion
Community Champion

@adoalan You can use SEARCH or FIND as an equivalent for CONTAINSSTRING



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...

@Greg_Deckler I tried but something is not working because I cannot get any results! 

Helpful resources

Announcements
Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.