Forum Discussion
Bug: Power Query ReplaceValue Bug related to replacing String with null
Hi, I think I have encountered a bug in the ReplaceValue function, where I applied conditional replacinng values:
For column [Assessment], I want to do if its value is "N/A", then replace it with null, if its value is ..., then .... But I noticed that replacing "N/A" with null doesn't work. It works if I replace "N/A" with any other values. This is so strange. But make it even more strange, the same code works on another data table!
1st screenshot is the step before the replaceValue, and 2nd is the ReplaceValue step, and 3rd screenshot is when I change null to "test". You can see that only when I use if [Assessment]= "N/A" then null it doesn't work.
anyone can pin down a coding error? or it's really a Power Query bug?
Thanks
3 Replies
- AhmedxSuper User
you try changing N/A to null first
= Table.ReplaceValue(Source,"N/A",null,Replacer.ReplaceValue,{"Assessment"})- alwangFrequent Visitor
Thanks. I know. But my question is that why my code works one table, but not on this table
- AhmedxSuper User
rewrite the code like this and it will work
= Table.ReplaceValue( #"Changed Type", (x)=>x, (x)=>x , (x,y,z)=> if x = "N/A" then null else if x = "Blouse" or x ="Kosovorotka" then "AAAA" else x,{"Assessment"})