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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
han_rj
Helper IV
Helper IV

Replace Strings M query

 

Hi

 

I would like to achieve an optimal Mquery where In Side , Sun Side, Side should be replaced with Header annd others should  remain.

Issue faced using UI was that I had to create multiple replace transformation and when tried replacing Side all the rows were affected.

Thank You in advance for the help

han_rj_2-1737639717036.png

 

 

 

1 ACCEPTED SOLUTION
v-mdharahman
Community Support
Community Support

Hi @han_rj,

Thanks for reaching out to the Microsoft fabric community forum.

 

It looks like you want to replace selected values from rows with "Header" value and you want to use MQuery so that you don't have to create multiple transformation.

Here is the MQuery to replace selected data rows from your desired data:

vmdharahman_0-1737704117458.png

Here "textColumn" is the name of the column in which you want to replace data with your desired data.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know. 

Best Regards,

Hammad.

Community Support Team

 

If this post helps then please mark it as a solution, so that other members find it more quickly.

Thank you.

View solution in original post

3 REPLIES 3
PwerQueryKees
Super User
Super User

I totally agree wit the solution of @v-mdharahman .

Here as copy/paste-able text:

 

= Table.TransformColumns (Source,
    {{"TextColumn", each if List.Contains(ReplacementList, Text.Trim(_)) then "Header" else _, type text}}
)

 

v-mdharahman
Community Support
Community Support

Hi @han_rj,

Thanks for reaching out to the Microsoft fabric community forum.

 

It looks like you want to replace selected values from rows with "Header" value and you want to use MQuery so that you don't have to create multiple transformation.

Here is the MQuery to replace selected data rows from your desired data:

vmdharahman_0-1737704117458.png

Here "textColumn" is the name of the column in which you want to replace data with your desired data.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know. 

Best Regards,

Hammad.

Community Support Team

 

If this post helps then please mark it as a solution, so that other members find it more quickly.

Thank you.

jgeddes
Super User
Super User

This may work for you...

Table.ReplaceValue(#"Changed Type", each [Strings], each if List.Contains({"In Side", "Sun Side", "Side"}, [Strings]) then "Header" else [Strings], Replacer.ReplaceValue, {"Strings"})




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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