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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
joep78
Helper III
Helper III

value based on specific characters

Hi all,

 

I'm looking for a DAX query that will fill in the column 'Outcome' as follow:

If Type is "Sensor 1" AND Space Contains "A", OR " B" OR "C"  then NAME A

If Type is "Sensor 1" AND Space does not Contains "A", OR " B" OR "C"  then NAME B

If Type is "Sensor 2" AND Space does Contains "A", OR " B" then NAME C

If Type is "Sensor 2" AND Space does not Contains "A", OR " B" then NAME D

If Type is "Sensor 2" AND Space is emtpy  then NAME E

 

 

TypeSpaceOutcome
sensor 112AName A
sensor 112BName A
sensor 112Name B
Sensor 213CName C
Sensor 213Name D
Sensor 2 Name E

 

I was not able to achive this, hopefully anybody can help me out! Thanks in advance.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @joep78 

Please check the below.

it is for creating a new column.

 

Picture2.png

 

Outcome CC =
SWITCH (
TRUE (),
'Table'[Type] = "sensor 1"
&& OR (
CONTAINSSTRING ( 'Table'[Space], "A" ),
CONTAINSSTRING ( 'Table'[Space], "B" )
), "NAME A",
'Table'[Type] = "Sensor 1"
&& NOT CONTAINSSTRING ( 'Table'[Space], "A" )
&& NOT CONTAINSSTRING ( 'Table'[Space], "B" )
&& NOT CONTAINSSTRING ( 'Table'[Space], "C" ), "NAME B",
'Table'[Type] = "Sensor 2"
&& OR (
CONTAINSSTRING ( 'Table'[Space], "A" ),
OR (
CONTAINSSTRING ( 'Table'[Space], "C" ),
CONTAINSSTRING ( 'Table'[Space], "B" )
)
), "NAME C",
'Table'[Type] = "Sensor 2"
&& NOT CONTAINSSTRING ( 'Table'[Space], "A" )
&& NOT CONTAINSSTRING ( 'Table'[Space], "B" )
&& 'Table'[Space] <> BLANK (), "NAME D",
'Table'[Type] = "Sensor 2"
&& 'Table'[Space] = BLANK (), "Name E"
)

 

 

https://www.dropbox.com/s/qkx7v34mo53yabf/joep.pbix?dl=0 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @joep78 

Please check the below.

it is for creating a new column.

 

Picture2.png

 

Outcome CC =
SWITCH (
TRUE (),
'Table'[Type] = "sensor 1"
&& OR (
CONTAINSSTRING ( 'Table'[Space], "A" ),
CONTAINSSTRING ( 'Table'[Space], "B" )
), "NAME A",
'Table'[Type] = "Sensor 1"
&& NOT CONTAINSSTRING ( 'Table'[Space], "A" )
&& NOT CONTAINSSTRING ( 'Table'[Space], "B" )
&& NOT CONTAINSSTRING ( 'Table'[Space], "C" ), "NAME B",
'Table'[Type] = "Sensor 2"
&& OR (
CONTAINSSTRING ( 'Table'[Space], "A" ),
OR (
CONTAINSSTRING ( 'Table'[Space], "C" ),
CONTAINSSTRING ( 'Table'[Space], "B" )
)
), "NAME C",
'Table'[Type] = "Sensor 2"
&& NOT CONTAINSSTRING ( 'Table'[Space], "A" )
&& NOT CONTAINSSTRING ( 'Table'[Space], "B" )
&& 'Table'[Space] <> BLANK (), "NAME D",
'Table'[Type] = "Sensor 2"
&& 'Table'[Space] = BLANK (), "Name E"
)

 

 

https://www.dropbox.com/s/qkx7v34mo53yabf/joep.pbix?dl=0 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Hi Jihwan Kim,

 

Thanks for this, really helpful! 

 

Regards, Joep

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.