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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Adamc
New Member

Search, Isolate, and Transform Single Words in Phrase

Is it possible to isolate and transform a single word or phrase in excel power query instead of transforming the text in the entire cell?

 

For example, I have a column of text with 300 words per row. I want to search within the text for a word or phrase from a list of keyword that comes from a different table. Every occurrence where a keyword is found in the text I want to capitalize that keyword. 

I can almost accomplish what I am explaining here but right now I am only able to capitalize the entire row of text when a keyword is found. How can I isolate a single word without changing the rest of the text in the row?

 

  • Example Kayword to Search For: "summer"
  • Example Text Passage: "It's a wonderful summer day today. Last summer didn't have this nice of weather."
    Example Output: "It's a wonderful SUMMER day today. Last SUMMER didn't have this nice of weather."
4 REPLIES 4
ppm1
Solution Sage
Solution Sage

You can split the text at the spaces with Text.Split to make a list and then apply a transform for just the "summer" elements and then recombine with spaces.

 

ppm1_0-1686926365276.png

 

= Text.Combine(List.Transform(Text.Split([TextColumn], " "), each if _ = "summer" then Text.Upper(_) else _), " ")

 

Pat

Microsoft Employee

@ppm1 

Is it possible to use "replace" to replace a keyword or phrase from my list with the capitalized version?

@ppm1 Thanks for the response.

 

Some of the keywords and phrases I'm searching for have spaces in them so imagine the keyword in the above example was "last summer" so I want to output "LAST SUMMER". How can I account for this if I don't want to split the text by each space?

In that case, see scenario 5 in this article - Replace Values in Power Query M (Ultimate Guide) - BI Gorilla

 

Pat

 

Microsoft Employee

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors