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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
nandukrishnavs
Super User
Super User

How can i replace the value of one column with another column in query editor

I have Table with two column. first column is "Indicator" and second column is "Sub-Indicator". I want to replace all the indicator value with coresponding Sub-Indicator value. 


Regards,
Nandu Krishna

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@nandukrishnavs,

Add a new blank query in Power BI Desktop, then paste the following code into Advanced Editor of the blank query. Please note that the highlighted code do the replace value job.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUUpRitWJVnICslLBLGcgK00pNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Indicator = _t, #"Sub-Indicator" = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,each [Indicator],each [#"Sub-Indicator"],Replacer.ReplaceText,{"Indicator"})
in
    #"Replaced Value"


Another method is to duplicate the sub-indicator column, and then remove the Indicator column.
0.PNG
Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yuezhe-msft
Employee
Employee

 
Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-yuezhe-msft
Employee
Employee

@nandukrishnavs,

Add a new blank query in Power BI Desktop, then paste the following code into Advanced Editor of the blank query. Please note that the highlighted code do the replace value job.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUUpRitWJVnICslLBLGcgK00pNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Indicator = _t, #"Sub-Indicator" = _t]),
    #"Replaced Value" = Table.ReplaceValue(Source,each [Indicator],each [#"Sub-Indicator"],Replacer.ReplaceText,{"Indicator"})
in
    #"Replaced Value"


Another method is to duplicate the sub-indicator column, and then remove the Indicator column.
0.PNG
Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
nandukrishnavs
Super User
Super User

I tried this formula 

 

Table.ReplaceValue(#"Renamed Columns4", each [Indicator],"", Replacer.ReplaceValue,{"Sub-Indicator"})

 

But few Indicator values remains the same. 


Regards,
Nandu Krishna

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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