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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
kb19270
Frequent Visitor

undefined

I have a column in a table which contains text. I would like to create another column from this which will show a text (i have 3 text that i want to find)  if any of these texts is found in the other column and blank if it doesn't contain any of the 3 texts. I am guessing contain or containstring function should do but not sure how.

Please see example below

 

Column A                                                               Column B

General wear  replace part                                   General wear       

Contamination oil drop found                             Contamination

vaccuum clean                                                        -

other machine moved                                            other   

contamination dropped oil                                  contamination

1 ACCEPTED SOLUTION
rsbin
Super User
Super User

@kb19270 ,

You are right to use CONTAINSSTRING, but combined with the SWITCH function.  Acts very much like a nested IF, but much easier to use and read:

ColumnB = SWITCH(
              TRUE(),
              CONTAINSSTRING( [Column A], "General wear" ), "General wear",
              CONTAINSSTRING( [Column A], "Contamination" ), "Contamination",
              CONTAINSSTRING( [Column A], "other" ), "other",
              "-" )

rsbin_0-1666975355589.png

Trust you will be able to make this work for you.

Regards,

View solution in original post

1 REPLY 1
rsbin
Super User
Super User

@kb19270 ,

You are right to use CONTAINSSTRING, but combined with the SWITCH function.  Acts very much like a nested IF, but much easier to use and read:

ColumnB = SWITCH(
              TRUE(),
              CONTAINSSTRING( [Column A], "General wear" ), "General wear",
              CONTAINSSTRING( [Column A], "Contamination" ), "Contamination",
              CONTAINSSTRING( [Column A], "other" ), "other",
              "-" )

rsbin_0-1666975355589.png

Trust you will be able to make this work for you.

Regards,

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.