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
nataliesmiy1357
Helper IV
Helper IV

Create a column "if the cell contains"

Hello!  I am looking to create a column in my table to create a personalized filter.

 

I am wanting to create a column that is basically "if this cell contains x, y, and z, print Unit"

 

This is what I wrote... but it isn't working right now.  Just not sure how to create this formula.

 

 

Type of Plant =
IF(CONTAINS(Merge1, Merge1[Plant and Line], "TMMAL", Merge1[Plant and Line], "TMMK PWT", Merge1[Plant and Line], "TMMWV"), "Unit",
IF(CONTAINS(Merge1, Merge1[Plant and Line], "TMMBC", Merge1[Plant and Line], "TMMI", Merge1[Plant and Line], "TMMK", Merge1[Plant and Line], "TMMC", Merge1[Plant and Line], "TMMGT", Merge1[Plant and Line], "TMMTX"), "Vehicle",
"NEED TO INCLUDE"))
 
Thanks in advance!
2 ACCEPTED SOLUTIONS

I tried that... but it didn't work.  My data that I'm pulling from looks like this:

January TMMWV TNGA

 

So I need to pull if that line has TMMWV, print Unit.

 

Thanks again!

View solution in original post

@nataliesmiy1357,

 

Try this:

 

Type of Plant =
SWITCH (
    TRUE,
    CONTAINSSTRING ( Merge1[Plant and Line], "TMMAL" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMK PWT" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMWV" ), "Unit",
    CONTAINSSTRING ( Merge1[Plant and Line], "TMMBC" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMI" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMK" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMC" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMGT" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMTX" ), "Vehicle",
    "NEED TO INCLUDE"
)

 

DataInsights_0-1714752001522.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
DataInsights
Super User
Super User

@nataliesmiy1357,

 

Try this calculated column:

 

Type of Plant = 
SWITCH (
    TRUE,
    Merge1[Plant and Line] IN { "TMMAL", "TMMK PWT", "TMMWV" }, "Unit",
    Merge1[Plant and Line] IN { "TMMBC", "TMMI", "TMMK", "TMMC", "TMMGT", "TMMTX" }, "Vehicle",
    "NEED TO INCLUDE"
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I tried that... but it didn't work.  My data that I'm pulling from looks like this:

January TMMWV TNGA

 

So I need to pull if that line has TMMWV, print Unit.

 

Thanks again!

@nataliesmiy1357,

 

Try this:

 

Type of Plant =
SWITCH (
    TRUE,
    CONTAINSSTRING ( Merge1[Plant and Line], "TMMAL" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMK PWT" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMWV" ), "Unit",
    CONTAINSSTRING ( Merge1[Plant and Line], "TMMBC" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMI" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMK" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMC" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMGT" )
        || CONTAINSSTRING ( Merge1[Plant and Line], "TMMTX" ), "Vehicle",
    "NEED TO INCLUDE"
)

 

DataInsights_0-1714752001522.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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