I'm using Power Query in excel and I'm trying to use the ReplaceValues Function with IF statements on a string column and for some reason it's not working with the blank cells. Below is my code.
=Table.ReplaceValue(#"Previous Step",
each [Column1],
each if [Column1] = "" or [Column1] = null then "n/a"
else if [Column1] = "Strings" or [Column1] = "Strings2" then "Yes"
else [Column1],
Replacer.ReplaceText,{"Column1"})
I also tried this with no success:
=Table.ReplaceValue(#"Previous Step",
each [Column1],
each if Text.Trim([Column1]) = "" or [Column1] = null then "n/a"
else if [Column1] = "Strings" or [Column1] = "Strings2" then "Yes"
else [Column1],
Replacer.ReplaceText,{"Column1"})
I even tried putting a space between the ""
and that didn't work either. Are there any other solutions that I can use as a workaround so that my If Statement can pick up blank or empty cells?
null
is not text, so Replacer.ReplaceText
will not work. Use Replacer.ReplaceValue
instead.
I've just made that one change to your first code: