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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
doubleclick
Helper II
Helper II

Make Text.Replace Case Insensitive, should be easy but is not!

Hello everyone! 

 

I want to replace any instance of Ltd, whether it's ltd or LTD or Ltd that will appear as part of a string with a nothing. Plus, i have a few other words i want to do this with 

 

I did a simple right click, replace text and have been experimenting with where to put the comparer.orignalignorecase function but unable to determine!

 

Here's my formula:

= Table.ReplaceValue(#"Renamed Columns","LTD","",Replacer.ReplaceText,{"Supplier (cleansed)"})

 

Os anyone smart enough to help?

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

You can use below formula in a custom column

 

= Text.Combine(List.RemoveMatchingItems(Text.Split([#"Supplier (cleansed)"]," "),{"ltd"},Comparer.OrdinalIgnoreCase)," ")

 

 

View solution in original post

7 REPLIES 7
Rickmaurinus
Helper V
Helper V

Hi there,

 

If you purely want to remove a certain string, the marked solution works fine. If you want to replace the string with something else you can use the method in chapter 6.4 of my article: Replace Values in Power Query M (Ultimate Guide) - Gorilla BI

 

 

= Text.Combine(
     List.ReplaceMatchingItems (
          Text.Split( [Text], " " ) ,
          { { "ValueToReplace", "ValueToReplaceWith" } },
          Comparer.OrdinalIgnoreCase ),
     " ")

 

 

If you only want to remove List.RemoveMatchingItems works perfectly fine 🙂

 

Regards,

Rick de Groot

 

--------------------------------------------------

@ me in replies or I'll lose your thread

 

Master Power Query M? -> https://powerquery.how

Read in-depth articles? -> BI Gorilla

Youtube Channel: BI Gorilla

 

If this post helps, then please consider accepting it as the solution to help other members find it more quickly.

Vijay_A_Verma
Super User
Super User

You can use below formula in a custom column

 

= Text.Combine(List.RemoveMatchingItems(Text.Split([#"Supplier (cleansed)"]," "),{"ltd"},Comparer.OrdinalIgnoreCase)," ")

 

 

YOU SIR, ARE A GENIUS!

mahoneypat
Microsoft Employee
Microsoft Employee

Here's one way to do it.

 

In Transform/Format - make the column lower case

With Replace Values - replace " ltd" with ""

In Transform/Format - choose Capitalize Each Word

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


No i cannot, it ruins the whole column...

 

Not sure why this one problem is so difficult for you powerbi geniuses!

Greg_Deckler
Super User
Super User

@doubleclick Try something like:

= Table.ReplaceValue(
     #"Changed Type",
     each [Consumer_ID], 
     each if Text.Contains([Consumer_ID] ), "rick", 
           Comparer.OrdinalIgnoreCase ) then "Rick" else 
           [Consumer_ID],
     Replacer.ReplaceValue,
     {"Consumer_ID"}
 )

Replace Values in Power Query M (Ultimate Guide) - Gorilla BI

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Not sure this works. 

Say there's 3 entries:

1) Microsoft LTD

2) Google Ltd

3) Amazon ltd

 

I want the text replace to replace any instance of ltd with nothing, to delete it so i'm only left with the company name 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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