Forum Discussion
JoaoMS
5 years agoHelper III
Replace value in Power Query based on condition
Dear all, I have a table ("POs") with a list of POs which have some fields that in very specifics moments have wrong entry inputs. For example in the following table the PO "1006" should have the...
- Anonymous5 years ago
HI JoaoMS,
You can use replace value function with custom expression to add conditions to replace value steps:
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [Category],each if [PO]=1006 and [Category]="D" then "C" else [Category],Replacer.ReplaceText,{"Category"})Regards,
Xiaoxin Sheng
Anonymous
5 years agoNot applicable
HI JoaoMS,
You can use replace value function with custom expression to add conditions to replace value steps:
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [Category],each if [PO]=1006 and [Category]="D" then "C" else [Category],Replacer.ReplaceText,{"Category"})
Regards,
Xiaoxin Sheng
- Martin_Nagy3 years agoAdvocate I
I think you have an error in the syntax, should be Replacer.ReplaceValue instead of Replacer.ReplaceText. The whole line is thus:
#"Replaced Value" = Table.ReplaceValue(#"Changed Type",each [Category],each if [PO]=1006 and [Category]="D" then "C" else [Category],Replacer.ReplaceValue,{"Category"})- gabriel0072 years agoRegular Visitor
This worked for me, not the original answer
- JoaoMS5 years agoHelper IIIThank you, this is what I was looking for without creating a new column. I just made a small change "each if [PO]=1006 then "C" else [Category]", considering that there is just one PO named "1006" Regards