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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Extracting Specific Text from a String Type Column

I have a text string column in my dataset that contains random strings. However, some of the records contain location information within the strings. An example of this is: EU-Romania- Server and they are often in an arbitrary order, for instance the next record with location information maybe SS-B-EU.

 

If I wanted to extract "EU" from the records that contain "EU" in this field, what would I do?

 

1 ACCEPTED SOLUTION

@Anonymous I don't why wouldn't post these rules in your original post, how someone will get to know what to do. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Anyhow, add new column with following expression.

 

MyRegion = 
SWITCH ( TRUE(),
    SEARCH ( "EU", Table[Data], , -1 ) >= 0, "EU",
    SEARCH ( "Name", Table[Data], , -1) = -1 && SEARCH ( "NA", Table[Data], , -1 ) >= 0, "NA",
    SEARCH ( "APAC", Table[Data], , -1 ) >= 0, "APAC",
    ""
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

13 REPLIES 13
Anonymous
Not applicable

Yes so I want "NA" when it just says "NA" and isn't part of another word such as "name".

@Anonymous I don't why wouldn't post these rules in your original post, how someone will get to know what to do. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Anyhow, add new column with following expression.

 

MyRegion = 
SWITCH ( TRUE(),
    SEARCH ( "EU", Table[Data], , -1 ) >= 0, "EU",
    SEARCH ( "Name", Table[Data], , -1) = -1 && SEARCH ( "NA", Table[Data], , -1 ) >= 0, "NA",
    SEARCH ( "APAC", Table[Data], , -1 ) >= 0, "APAC",
    ""
)

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Thanks!

v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Do you want the result like this image?

3-1.PNG

Column =
VAR a =
    SEARCH ( "EU", 'Table'[Column1], 1, 0 )
RETURN
    IF ( a <> 0, "EU", 'Table'[Column1] )

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
parry2k
Super User
Super User

@Anonymous do you want to extract only EU value where available otherwise return empty. Is this correct?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi,

 

Thanks for getting back - "EU" and some other location values as well. Any idea as to how I might be able to do it?

@Anonymous do you have list of locations you want to search, if not then what would be business rule to identify that it is a location. You have to provide more information.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

 I am looking for "EU", "NA" and "APAC" between the texts -  I need the results in a single column. Please note, that I also have other values in this column that might contain this character (for example, Default-First-Name, contains "NA").

 

Thanks for your help!

 

 

 

 

@Anonymous can you paste sample data here in a table?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

I'll paste some sample values from this column:

 

Default-First-Site-Name

Azure-EU- North Europe ( I need EU from this value)

none

FR-Telecity

FIT

DE_MUC

TX95C

AWS-NA-East (I need just NA from this value)

 

 

 

 

 

 

 

 

@Anonymous is this the only value from which you don't want "NA" to extract? 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

There are around 70,0000 rows of data in this dataset so there maybe other values that contain "na" in the value.

@Anonymous that raised the question what would be the logic to ignore not to extract "NA" , you have to have some logic, isn't it?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.