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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
hidenseek9
Post Patron
Post Patron

How to extract certain words from text?

Hello Power BI Community,

 

I have a question regarding extracting certain words out from text.

Please find below as the dummy data created.

 

Sample Data

 

2018-02-08 16_02_17-Untitled - Query Editor.png

 

From this dummy data, I would like to do 3 things.

  1. If a text under column "Name" contains a word "Greek", I would like to create a column called "Type" and list "Greek" in it.
  2. If a text under column "Name" contains a size "1P/3P/4P/6P/8P", I would like to create a column called "Pot" and list the pot size. (if it is 1P sometimes, a text does not even contain "1P" in it, just as the very last example under "Name")
  3. If a text under column "Name" contains a word "CO_", I would like to create a column called "Costco" and list Costco in it.

2018-02-08 16_02_01-Dummy Data.xlsx - Excel.png

 

The final output that I desire is the screenshot above. 

There is no consistancy in the texts, but is there a way to achieve my goal?

 

Many thanks,

 

H

1 ACCEPTED SOLUTION
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @hidenseek9,

Please create calculatec column using the formulas below.

Type =
IF (
    IFERROR ( SEARCH ( "Greek", Sheet1[Name] ), 0 ) = 0,
    BLANK (),
    RIGHT (
        LEFT ( Sheet1[Name], IFERROR ( SEARCH ( "Greek", Sheet1[Name] ) + 4, 0 ) ),
        5
    )
)

Pot =
IF (
    IFERROR ( SEARCH ( "1P", Sheet1[Name] ), 0 )
        + IFERROR ( SEARCH ( "3P", Sheet1[Name] ), 0 )
        + IFERROR ( SEARCH ( "4P", Sheet1[Name] ), 0 )
        + IFERROR ( SEARCH ( "6P", Sheet1[Name] ), 0 )
        + IFERROR ( SEARCH ( "8P", Sheet1[Name] ), 0 )
        = 0,
    BLANK (),
    RIGHT (
        LEFT (
            Sheet1[Name],
            IFERROR ( SEARCH ( "1P", Sheet1[Name] ), 0 )
                + IFERROR ( SEARCH ( "3P", Sheet1[Name] ), 0 )
                + IFERROR ( SEARCH ( "4P", Sheet1[Name] ), 0 )
                + IFERROR ( SEARCH ( "6P", Sheet1[Name] ), 0 )
                + IFERROR ( SEARCH ( "8P", Sheet1[Name] ), 0 )
                + 1
        ),
        2
    )
)


Costco =
IF ( IFERROR ( SEARCH ( "CO_", Sheet1[Name] ), 0 ) = 0, BLANK (), "Costco" )


Please see expected result as follows, you can download attachment file for more details.

1.PNG

Best Regards,
Angelia

View solution in original post

2 REPLIES 2
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @hidenseek9,

Please create calculatec column using the formulas below.

Type =
IF (
    IFERROR ( SEARCH ( "Greek", Sheet1[Name] ), 0 ) = 0,
    BLANK (),
    RIGHT (
        LEFT ( Sheet1[Name], IFERROR ( SEARCH ( "Greek", Sheet1[Name] ) + 4, 0 ) ),
        5
    )
)

Pot =
IF (
    IFERROR ( SEARCH ( "1P", Sheet1[Name] ), 0 )
        + IFERROR ( SEARCH ( "3P", Sheet1[Name] ), 0 )
        + IFERROR ( SEARCH ( "4P", Sheet1[Name] ), 0 )
        + IFERROR ( SEARCH ( "6P", Sheet1[Name] ), 0 )
        + IFERROR ( SEARCH ( "8P", Sheet1[Name] ), 0 )
        = 0,
    BLANK (),
    RIGHT (
        LEFT (
            Sheet1[Name],
            IFERROR ( SEARCH ( "1P", Sheet1[Name] ), 0 )
                + IFERROR ( SEARCH ( "3P", Sheet1[Name] ), 0 )
                + IFERROR ( SEARCH ( "4P", Sheet1[Name] ), 0 )
                + IFERROR ( SEARCH ( "6P", Sheet1[Name] ), 0 )
                + IFERROR ( SEARCH ( "8P", Sheet1[Name] ), 0 )
                + 1
        ),
        2
    )
)


Costco =
IF ( IFERROR ( SEARCH ( "CO_", Sheet1[Name] ), 0 ) = 0, BLANK (), "Costco" )


Please see expected result as follows, you can download attachment file for more details.

1.PNG

Best Regards,
Angelia

@v-huizhn-msft

 

Oh my goodness.

This is working beautifully. Amazing.

 

Thank you so much!

 

H

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors