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
OptoGuru
New Member

Replace text in column that contains a certain string

I am linking to an external web database in excel and using the power query editor to transform some cell contents using the "Replace Values" feature.  However, I want to find cells that contain a certain string value and then replace the entire cell with another string.  So an example column dataset would be:

 

bowl1

bowl2

bowl1

bowl5

bowl4

 

I would like to find the string "bowl" and then replace it with "Bowls"

 

It seems like I can only find a specific string and replace with another string. I assume there is an equation I can use for this, but couldn't quite find what it might be.

 

Thank you.

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @OptoGuru,

remove , Comparer.OrdinalIgnoreCase from my code if you want replace just bowl and not: Bowl, BOWL, bOWL etc.

dufoq3_0-1712005777206.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSsovzzFUitWJVipJLS6BsEBiRmCWoZExSBjGRihOTEoG045OziBBUzDHxNQMrt9EKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    ReplacedValue = Table.ReplaceValue(Source,
    each [Column1],
    each "Bowls",
    (x,y,z)=> if Text.Contains(y, "bowl", Comparer.OrdinalIgnoreCase) then z else x,
    {"Column1"} )
in
    ReplacedValue

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

1 REPLY 1
dufoq3
Super User
Super User

Hi @OptoGuru,

remove , Comparer.OrdinalIgnoreCase from my code if you want replace just bowl and not: Bowl, BOWL, bOWL etc.

dufoq3_0-1712005777206.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSsovzzFUitWJVipJLS6BsEBiRmCWoZExSBjGRihOTEoG045OziBBUzDHxNQMrt9EKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    ReplacedValue = Table.ReplaceValue(Source,
    each [Column1],
    each "Bowls",
    (x,y,z)=> if Text.Contains(y, "bowl", Comparer.OrdinalIgnoreCase) then z else x,
    {"Column1"} )
in
    ReplacedValue

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Kudoed Authors