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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors