Hi All,
I have a dataset with some missing data- simplified version below:
I’m trying to populate the missing ID values for Category Other1 and Other2 which I know can be done in a new column using IF or SWITCH statement.
Is it possible to conditionally set or change the value of the ID column in Power Query Editor without creating a new column? If so, can you please point me in the right direction on how to do this?
In Power Query, you can use the Replace Values command to do this. I wouldn’t recommend it if you have a lot of changes to make, but for a few it’s a handy way to accomplish just what you’re looking to do.
If you want to build in more complex conditional statements without adding a new column, you can go into the advanced editor and edit that code to include an IF statement(s).
Thanks Brian for your response. Yes, this is what I’m trying to do. The replace must be conditional. Not sure of the exact syntax to include if statement in advanced editor, but will give it a shot.
Thanks - good point. I thought of that as well - certainly a bit easier to implement, but I know that some of the folks in this situation have a strict constraint that they’re not allowed to add any columns or tables to the data model, even temporary ones. But I should have mentioned that in case @DeanJ doesn’t have that strict constraint.
As far as I know there is no way to do a conditional replace through the UI except for maybe creating a bunch of Replace Value steps (like @BrianJ already mentioned).
But it can be done with a bit of coding. Copy this script into a new blank query.
Amazing! When I first replied, I thought this would be a simple conditional based on ReplaceValue. I ended up working on it for a long time last night and couldn’t get this to work.
Let’s definitely put this one on the list for collaborative video solutions.
Hi @DeanJ, did the response provided by the experts help you solve your query? If not, how far did you get and what kind of help you need further? If yes, kindly mark as solution the answer that solved your query. Thanks!
Hi @DeanJ, we’ve noticed that no response has been received from you since September 10.
We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved.
Hi @DeanJ, due to inactivity, a response on this post has been tagged as “Solution”. If you have a follow question or concern related to this topic, please create a new thread.