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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DAX IF text contains

Hi Team,

 

I have Markets and i need output in status column,

 

DAX - if markets contains 40* then H else W

 

Pleas 

 

Capture1.PNG

Thanks,

KV's

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @Anonymous ,

 

you should be able to solve that with a calculated column and the function CONTAINSSTRING:

Status = IF( CONTAINSSTRING( myTable[Markets], "40" ), "H", "W" )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

6 REPLIES 6
Facil1126
New Member

Joining this thread . im trying to do the same but struggling . i also have a contains. 

i want to check if a value is in one column and another value in a different column. the tables have a direct relationship via another column :

Column 2 = IF('PM Matrix'[Vendor Only] = "Y" ,IF(CONTAINSSTRING(RELATED('Maint  Intervals & Job Plan'[Provider Path (Reference Only)]),"VENDOR"),"Y","N"))
 
so if the column on PM Matrix called Vendor is "Y", then, If Provider path on Maint intervals contains the word "VENDOR", then display a "Y", otherwise display a "N"
 
any help
Anonymous
Not applicable

Can you make this with multiple items for example by adding in || althouhg I get and error saying cannot convert value of type text to type true and false

Status = IF( CONTAINSSTRING( myTable[Markets], "40"||"50" ), "H", "W" )

 

selimovd
Super User
Super User

Hey @Anonymous ,

 

you should be able to solve that with a calculated column and the function CONTAINSSTRING:

Status = IF( CONTAINSSTRING( myTable[Markets], "40" ), "H", "W" )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Hey @selimovd 

Your response here really helped me, thank you!

 

I need to add an AND statement, but it's not working. Can you advise me please?

 

It would look something like this 

IF (CONTAINS STRING (Table Y [Column], "A"), AND CONTAINS STRING (Table X [Column], "A"), "B",  "C")

 

Thank you!

 

  

Hey @Carrhill ,

 

sure, you can combine them with the AND function:

Status =
IF (
    AND (
        CONTAINSSTRING ( 'Table Y'[Column], "A" ),
        CONTAINSSTRING ( 'Table X'[Column], "A" )
    ),
    "B",
    "C"
)

 

Or you can combine them with two &&:

Status =
IF (
    CONTAINSSTRING ( 'Table Y'[Column], "A" ) && CONTAINSSTRING ( 'Table X'[Column], "A" ),
    "B",
    "C"
)

 

Both should work the same way.

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍

Best regards
Denis

Blog: WhatTheFact.bi
Follow me: twitter.com/DenSelimovic

Hey @Anonymous ,

 

did it work with the calculated column I proposed?

I'm curious if you could solve this issue 🙂

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.