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
PANDAmonium
Resolver III
Resolver III

Replacing values based on another column

Hi All,

 

Happy Friday! So I'm trying to figure out how to replaced values based on another column and have something like this:

 

= Table.ReplaceValue(#"Removed Columns1", each [A], each if [B] = "inactive" then "B is inactive" else [A], Replacer.ReplaceText, {"A"})

 

Works great except with one exception. It does not replace null values of col A! 

 

Yeah, I get I can back out and do this by adding a new conditional column or by replacing null with "ugh" and replacing it back to null after I'm done. But this is more about getting better at Power Query M and understanding the forumla. Plus it's Friday and I want to end the week on a win instead of a compromise.

 

So it feels like there is something very minor we're missing to get it all done in that one line, but haven't had any luck so far. Let me know if you all have any ideas.

 

Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @PANDAmonium 

I think it is something very minor - try Replacer.ReplaceValue instead of Replacer.ReplaceText and let us know.

I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @PANDAmonium 

I think it is something very minor - try Replacer.ReplaceValue instead of Replacer.ReplaceText and let us know.

I hope this helps. If it does, please Mark as a solution.
I also appreciate Kudos.

That fixed it! I probably autofilled it and didn't notice the difference; then focused only on thinking it was an issue with the second parameter. But yeah, I'll remember that for next time and it should be really helpful here on.

 

Thanks @Anonymous !

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.