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
Barbs10
New Member

Replace value column A if value in column B=criteria

Hi!

I want to replace the value in one column if the value in a second column equals a criteria.

For example

Column A       Column B

A                     1

B                     2

 

I want to use the advanced editor so that if Column B=2, then Column A=C to get the result:

Column A       Column B

A                     1

C                     2

 

I have been trying to use this:

#"Replaced Value" =  if (each[Column B]=2) then Table.ReplaceValue(#"Table name", "B", "C",Text.Replace, {"Column A"} ) else null

 

But it is not working..Any ideas that don't require to use a conditional column (I have to do this replacements on a lot of columns...)

 

23 REPLIES 23

Sorry for the late response, I tried this on my own after posting the query and it worked as you have suggested. Thanks for your help and suggestions.

v-yulgu-msft
Employee
Employee

Hi @Barbs10,

 

Why don't you consider that solution using a conditional column? I think this is a very simple and valid solution in this scenario. For more advice, please make it more specific about your actual scenario.

 

Thanks,
Yuliana Gu

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

Hi @Barbs10

 

Please follow the link

https://community.powerbi.com/t5/Desktop/alter-values-in-one-column-based-on-a-value-in-another-colu...

 

specifically the content by LaurentCouartou.

 

After that Delete the orginal column A and rename the MyNewColumn as Column A

 

If this works please accept as solution and also give KUDOS to me and the linked article contributors.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

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.