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
WJ876400
Helper IV
Helper IV

Replace all in table not just a column

Hi,

 

I have a table of data from a survey and there are 6 questions that require a response of Strongly Agree, Agree, Neutral, Disagree and strongly agree. I want to add a number before each so I can sort the visuals. Is there a way to replace a value for all columns or will i have to do it individually for all columns.

 

So I want to replace all strongly agree with 1. Strongly Agree but dont want to have to do it by each column can I just do a replace all that finds strongly agree and then replace with 1. Strongly agree.

 

thanks in advance

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@WJ876400 , Try using below Power Query for this

 

let
    Source = YourDataSource,
    ReplaceValues = Table.TransformColumns(Source, List.Transform(Table.ColumnNames(Source), each {_, each Text.Replace(_, "Strongly Agree", "1. Strongly Agree"), type text})),
    ReplaceValues2 = Table.TransformColumns(ReplaceValues, List.Transform(Table.ColumnNames(ReplaceValues), each {_, each Text.Replace(_, "Agree", "2. Agree"), type text})),
    ReplaceValues3 = Table.TransformColumns(ReplaceValues2, List.Transform(Table.ColumnNames(ReplaceValues2), each {_, each Text.Replace(_, "Neutral", "3. Neutral"), type text})),
    ReplaceValues4 = Table.TransformColumns(ReplaceValues3, List.Transform(Table.ColumnNames(ReplaceValues3), each {_, each Text.Replace(_, "Disagree", "4. Disagree"), type text})),
    ReplaceValues5 = Table.TransformColumns(ReplaceValues4, List.Transform(Table.ColumnNames(ReplaceValues4), each {_, each Text.Replace(_, "Strongly Disagree", "5. Strongly Disagree"), type text}))
in
    ReplaceValues5
 
replace yourdatasource with actual source



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

Proud to be a Super User!




LinkedIn






View solution in original post

2 REPLIES 2
WJ876400
Helper IV
Helper IV

Thank you very much

bhanu_gautam
Super User
Super User

@WJ876400 , Try using below Power Query for this

 

let
    Source = YourDataSource,
    ReplaceValues = Table.TransformColumns(Source, List.Transform(Table.ColumnNames(Source), each {_, each Text.Replace(_, "Strongly Agree", "1. Strongly Agree"), type text})),
    ReplaceValues2 = Table.TransformColumns(ReplaceValues, List.Transform(Table.ColumnNames(ReplaceValues), each {_, each Text.Replace(_, "Agree", "2. Agree"), type text})),
    ReplaceValues3 = Table.TransformColumns(ReplaceValues2, List.Transform(Table.ColumnNames(ReplaceValues2), each {_, each Text.Replace(_, "Neutral", "3. Neutral"), type text})),
    ReplaceValues4 = Table.TransformColumns(ReplaceValues3, List.Transform(Table.ColumnNames(ReplaceValues3), each {_, each Text.Replace(_, "Disagree", "4. Disagree"), type text})),
    ReplaceValues5 = Table.TransformColumns(ReplaceValues4, List.Transform(Table.ColumnNames(ReplaceValues4), each {_, each Text.Replace(_, "Strongly Disagree", "5. Strongly Disagree"), type text}))
in
    ReplaceValues5
 
replace yourdatasource with actual source



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

Proud to be a Super User!




LinkedIn






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.