Forum Discussion

Shaz_1985's avatar
Shaz_1985
New Member
2 years ago
Solved

Trying to replace based on another column not working due to target column having a null value

Wierd one, but I have spent 2 hours trying to figure this out without coming up with a good solution.

 

Here is the data exerpt:

For the team member Corina I want to remove the phone number that current exists in the wrong column (i.e. Emergency Contact: Emergency Contact Name) into the "Phone" column.

 

The code I used is below, however, as the current value in the cell is null it will not replace the null value with the Phone number. Only when I put in a workaround or step before to replace all nulls in the Phone column with a non-blank value (e.g. "1") does the below formula then apply correctly. Do I need to put an additional condition to check if the target cell is a null?

 

 

 

= Table.ReplaceValue(
        #"Replaced Value2",
        each[#"Phone"],
        each if [#"Emergency Contact: Emergency Contact Name"]="+44 7478 505510" then "+44 7478 505510" else [#"Phone"],
        Replacer.ReplaceText,{"Phone"})

 

 

 

 

2 Replies