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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Containsstring AND

Hello Everyone,
My goal is to change terms to "C" in two conditions:
1. If terms are A and Mat is X
2. If terms are B and column Mat contains a string XE (in its line item names)
 
I am confused if my usage of Containsstring is right in this case. Please help me out!
 
Column = if(
(
(Table[TERMS] = {"A"} && Table[Mat] in {"X"})
|| (Table[TERMS] = {"B"} && CONTAINSSTRING(Table[Mat],"XE")
),
C,
TABLE[TERMS]
)
 
 
1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi , @Anonymous 

There are some minor errors in format. 

The table name is recommended to be enclosed in quotation marks, and the values "A", "B", "C"  only  need to be enclosed in quotation.

colummn =
IF (
    ( 'Table'[TERMS] = "A"
        && 'Table'[Mat] IN { "X" } )
        || (
            'Table'[TERMS] = "B"
                && CONTAINSSTRING ( 'Table'[Mat], "XE" )
        ),
    "C",
    'Table'[TERMS]
)

 

203.png

 

PS:You can check whether there is an error in the sentence through this website, but the specific error still has to be debugged by yourself
http://www.daxformatter.com/

 

 

Best Regards,
Community Support Team _ Eason

View solution in original post

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

Hi , @Anonymous 

There are some minor errors in format. 

The table name is recommended to be enclosed in quotation marks, and the values "A", "B", "C"  only  need to be enclosed in quotation.

colummn =
IF (
    ( 'Table'[TERMS] = "A"
        && 'Table'[Mat] IN { "X" } )
        || (
            'Table'[TERMS] = "B"
                && CONTAINSSTRING ( 'Table'[Mat], "XE" )
        ),
    "C",
    'Table'[TERMS]
)

 

203.png

 

PS:You can check whether there is an error in the sentence through this website, but the specific error still has to be debugged by yourself
http://www.daxformatter.com/

 

 

Best Regards,
Community Support Team _ Eason

Anonymous
Not applicable

HI @Anonymous 

Column = if(((Table[TERMS]="A" && Table[Mat]="X")||(Table[TERMS] = "B" && FIND("XE",Table[Mat])>0),
C,TABLE[TERMS])

 FiND is a better option in this scenario as CONTAiNSSTRiNG is used to match patters and we are not looking for a pattern.

Tahreem24
Super User
Super User

Well, it looks correct. Are you facing any issue while writing that dax?

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
az38
Community Champion
Community Champion

@Anonymous 

why not? it looks correct but i would write it as

Column = if(
(
(Table[TERMS] = "A" && Table[Mat] = "X")
|| 
(Table[TERMS] = "B" && CONTAINSSTRING(Table[Mat],"XE")
),
C,
TABLE[TERMS]
)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.