Forum Discussion
Replacing Value Based on Two Conditions in Power Query
I have a list of people who have access to a certain Site Collection and Subsite. I am trying to replace a value in the Subsite column using an If-Else statement in Power Query to only replace one value if it meets the criteria.
Specifically, if the Site Collection is equal to "en_ca" and the Subsite is equal to "D26 Plumbing", I want to replace the Subsite text with "D26 Plumbing and Bath".
I've tried a few different equations but I either replace everything in the list with "D26 Plumbing and Bath" or I get an error.
= Table.ReplaceValue(#"Filtered Rows", each [Subsite], each if [SiteCollection]="en_ca" and [Subsite]<>"D26 Plumbing" then [Subsite] else "D26 Plumbing & Bath", Replacer.ReplaceValue,{"Subsite"})
What am I missing here?
= Table.ReplaceValue(#"Filtered Rows", each [Subsite], each if [SiteCollection]="en_ca" and [Subsite]="D26 Plumbing" then "D26 Plumbing & Bath" else [Subsite] , Replacer.ReplaceValue,{"Subsite"})
Does this return the intended result?
2 Replies
- OliverScheurichGold Contributor
= Table.ReplaceValue(#"Filtered Rows", each [Subsite], each if [SiteCollection]="en_ca" and [Subsite]="D26 Plumbing" then "D26 Plumbing & Bath" else [Subsite] , Replacer.ReplaceValue,{"Subsite"})
Does this return the intended result?
- renee_crozierBrass Contributor
It did! For my knowledge, the Replacer at the end of the code is just there to say where the replacement is taking place and has no important to the main if-else statement? I think that's what was tripping me up the most