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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
DanielCooper
Regular Visitor

Conditional replace text based on if the value is present in another column in the same row

Hi,

 

I'm having trouble using the Table.ReplaceValue function with a condition. 

 

I want to replace the values in one field (Print), with the values in another field (REPLACE Print), but only if the value on that row in the 'REPLACE Print' field is there. 

 

For example I have a lot of rows where I have a value in the 'Print' column which needs to be replaced with the new value in the 'REPLACE Print' column. But also some null rows in the 'Print' column which need to be replaced with the value in 'REPLACE Print' column.

 

Can anyone advise how I fix this formula, I want to minimise adding helper columns and instead do the whole task in the one step.

 

#"Replaced print" = Table.ReplaceValue(#"Replaced end use", each [Print], each if [REPLACE Print] = null then [Print] else [REPLACE Print], Replacer.ReplaceText,{"Print"})

 

Many thanks in advanced!

 

Best,

 

Dan

 

DanielCooper_0-1667516700673.png

 

 

1 ACCEPTED SOLUTION
jennratten
Super User
Super User

Hello!  Please give this a try...

= Table.ReplaceValue(#"Previous Step Name", each [Print], each [REPLACE Print] ?? [Print], Replacer.ReplaceValue,{"Print"})

This statement says exactly what you are trying to do.  The other difference between it and your script is that you had the replacer function as Replacer.ReplaceText (partial value) instead of Replacer.ReplaceValue (entire value).

BEFORE:

jennratten_0-1667517157293.png

 

AFTER:

jennratten_1-1667517180374.png

 

View solution in original post

3 REPLIES 3
jennratten
Super User
Super User

Hello!  Please give this a try...

= Table.ReplaceValue(#"Previous Step Name", each [Print], each [REPLACE Print] ?? [Print], Replacer.ReplaceValue,{"Print"})

This statement says exactly what you are trying to do.  The other difference between it and your script is that you had the replacer function as Replacer.ReplaceText (partial value) instead of Replacer.ReplaceValue (entire value).

BEFORE:

jennratten_0-1667517157293.png

 

AFTER:

jennratten_1-1667517180374.png

 

Hey! 

This worked great, thank you

 

Best,

 

Dan

Wonderful!  Please consider giving my solution a thumbs-up and marking it as an accepted solution.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors