The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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
Solved! Go to Solution.
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:
AFTER:
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:
AFTER:
Hey!
This worked great, thank you
Best,
Dan
Wonderful! Please consider giving my solution a thumbs-up and marking it as an accepted solution.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.