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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

replace values based on column from different query

Hi there, Sorry this seems to be pretty easy but for some reason it doesn't work for me. I have query 1 with 2 columns which are region name and region code, and I have second query only with region code column. I'm trying to replace the region codes in second query with corresponding region names from the first query. The following is my code. It doesn't through any errors but it does nothing, so I'm not sure what am i doing wrong. Thanks! Custom1 = Table.ReplaceValue(#"Removed Other Columns",each TestQuery1[Region],each TestQuery1[Region Name],Replacer.ReplaceValue,{"Region"})

6 REPLIES 6
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Have you tried to merge them ?

Be aware with start/end spaces and upper/lower.



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

Proud to be a Super User!



Anonymous
Not applicable

Thanks @camargos88 for your response. Merging does work but I have pretty big tables and further actions makes it pretty time consuming and affects the performance badly, so I would prefer to not use merge function at this stage.

@Anonymous ,

 

You cannot replace values from one table to another without a merge/lookup (using table/list).

Another option is creating a relationship between them.



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

Proud to be a Super User!



Anonymous
Not applicable

@camargos88 can I create relationship in power query or do i have to use power BI desktop for that?

Anonymous
Not applicable

@camargos88 is it possible to kind of link the 2 queries as below? Once again it doesn't though any errors but it doesn't work

let
Source = Web.Page(Web.Contents("SOME URL")),
Data0 = Source{0}[Data],
#"Changed Type" = Table.TransformColumnTypes(Data0,{{"Region Name", type text}, {"Region", type text}, {"Endpoint", type text}, {"Protocol", type text}}),
#"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Region"}),
Source1 = TestQuery1,
#"Region Name" = Source1[Region Name],
#"Converted to Table" = Table.FromList(#"Region Name", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Region" = Source1[Region Name],
#"Converted to Table1" = Table.FromList(#"Region", Splitter.SplitByNothing(), null, null, ExtraValues.Error),
Custom1 = Table.ReplaceValue(#"Removed Other Columns",each #"Region",each #"Region Name",Replacer.ReplaceValue,{"Region"})
in
Custom1

@Anonymous ,

 

create it on the model view, out of power query.



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

Proud to be a Super User!



Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.