Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi folks, I'll give you some background story to my case.
the code line that is on repeat has this syntax:
if Text.Contains([Description], "keyword from string", Comparer.OrdinalIgnoreCase) then "Standard Name" else if
...
else null, type text
I read something similar in this link (https://stackoverflow.com/questions/54368921/find-and-replace-using-wildcard-in-power-bi) but I am not sure if I can reproduce the similar results. I am also not familiar about the use of => in M. If anyone here can show and explain to me where and how I could use => in my M script, it would be much appreciated!
Solved! Go to Solution.
Hi @Alex_Ooi
Yes, there could be a misunderstanding, but my solution was expected to work on the original data table. Pls check enclosed file.
If that doesn't work, you can send the file to info at.. thebiccountant.com.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @Alex_Ooi ,
The best option is the M champion @ImkeF .
Can you please check this @ImkeF ,
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Alex_Ooi ,
How is the desired behaviour if multiple items match: Do you only want to replace the first match or subsequent as well?
Is it all the same transformation, just with different "if" and "then" strings?
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
@ImkeF thank you so much for reaching out to me!
Looking forward to hearing from you soon.
Hi @Alex_Ooi
you can create a "Translation"-table with columns "Old String" (contains the string to search for) and "New String" (the replacement).
Then add a column with this formula:
Table.SelectRows(Translation, (t) => Text.Contains([Column1], t[Old String], Comparer.OrdinalIgnoreCase)) {0}[New String]
It will return the correct values for matches and an error when no match is found.
You can use try .. otherwise to fetch the error or simply replace errors afterward with the desired default-value.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
I'm sorry @ImkeF I think I wasn't making myself clear. I want to create a column in my current data table. Can I replicate this by using Table.AddColumns?
Also, I think I have misunderstood your question on "multiple matches". I thought you meant multiple matches in the column I am searching for using Text.Contains. Can I know how I could send my script to you? I guess my script would be a better explanation than what I am trying to tell you with words.
Once again, apologies for the confusion.
Hi @Alex_Ooi
Yes, there could be a misunderstanding, but my solution was expected to work on the original data table. Pls check enclosed file.
If that doesn't work, you can send the file to info at.. thebiccountant.com.
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 84 | |
| 49 | |
| 37 | |
| 30 | |
| 30 |