cancel
Showing results for
Did you mean:
Post Partisan

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

Thanks,

KV's

1 ACCEPTED SOLUTION
Super User

Hey @Udt_KV ,

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

5 REPLIES 5
Helper II

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" )``

Super User

Hey @Udt_KV ,

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

Helper I

Hey @selimovd

Your response here really helped me, thank you!

It would look something like this

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

Thank you!

Super User

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

Super User

Hey @Udt_KV ,

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

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

#### Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors