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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
matts29
Frequent Visitor

DAX help containstring

Hi, someone please help with my dax below?
 
currently I have the below:
CurrentIn= if(AND(ED_Performance[DepartureDttm]=blank(),
CONTAINSSTRING(ED_Performance[CurrentLocation],"theatre")),1,0)
 
I would like to seach for multiple stings in the same column so idwally i would like added in 'Red'
CurrentIn= if(AND(ED_Performance[DepartureDttm]=blank(),
CONTAINSSTRING(ED_Performance[CurrentLocation],"theatre")
CONTAINSSTRING(ED_Performance[CurrentLocation],"theatre"),
CONTAINSSTRING(ED_Performance[CurrentLocation],"hall"),
CONTAINSSTRING(ED_Performance[CurrentLocation],"attic")
 ),1,0)
 
 
Thank you so much ๐Ÿ™‚
2 ACCEPTED SOLUTIONS

OR only get two conditions

or(con1,or(con2,con3))

View solution in original post

Anonymous
Not applicable

Hi @matts29 ,
As wdx223_Daniel mentioned, you can try the following code.

CurrentIn = 
IF(
    AND(
        ED_Performance[DepartureDttm] = BLANK(),
        OR(
            CONTAINSSTRING(ED_Performance[CurrentLocation], "theatre"),
            OR(
                CONTAINSSTRING(ED_Performance[CurrentLocation], "hall"),
                CONTAINSSTRING(ED_Performance[CurrentLocation], "attic")
            )
        )
    ),
    1,
    0
)

 

Best regards,
Albert He


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

4 REPLIES 4
DataNinja777
Super User
Super User

@matts29 ,

 

To handle multiple search strings in the same column, you can use the OR function in DAX to check for each condition. Hereโ€™s the updated formula that includes "theatre," "hall," and "attic" in your logic:

CurrentIn = 
IF(
    AND(
        ED_Performance[DepartureDttm] = BLANK(),
        OR(
            CONTAINSSTRING(ED_Performance[CurrentLocation], "theatre"),
            CONTAINSSTRING(ED_Performance[CurrentLocation], "hall"),
            CONTAINSSTRING(ED_Performance[CurrentLocation], "attic")
        )
    ),
    1,
    0
)

 

  • The OR function is used to combine the multiple CONTAINSSTRING checks. If any of the strings ("theatre," "hall," or "attic") are found in the CurrentLocation column, the condition evaluates to TRUE.
  • The AND function ensures that both DepartureDttm being blank and one of the strings being present are true for the result to be 1.
  • If neither condition is met, the result is 0.

 

This way, you can search for multiple strings in the same column and maintain the desired logic. If you need to add more strings, simply include additional CONTAINSSTRING functions within the OR block.

 

Best regards,

Thanks so much for the help and explanation  but I am getting the following error "Too many arguments were passed to the OR function. The maximum argument count for the function is 2." ? 

 

Thanks again

OR only get two conditions

or(con1,or(con2,con3))

Anonymous
Not applicable

Hi @matts29 ,
As wdx223_Daniel mentioned, you can try the following code.

CurrentIn = 
IF(
    AND(
        ED_Performance[DepartureDttm] = BLANK(),
        OR(
            CONTAINSSTRING(ED_Performance[CurrentLocation], "theatre"),
            OR(
                CONTAINSSTRING(ED_Performance[CurrentLocation], "hall"),
                CONTAINSSTRING(ED_Performance[CurrentLocation], "attic")
            )
        )
    ),
    1,
    0
)

 

Best regards,
Albert He


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

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric 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.

Users online (27)