Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Copy column in Power Query based on condition

Hi,

 

I have a dataset similar to the below.

 

SupervisorAreaBlock
Alan11A
Marc21B
Alan31C
John41C
Fred52
Fred54

 

I want to create a new column called 'Supervisor new' which copies over the data from supervisor but with the below condition.

 

If 'area' = '1' change 'Supervisor new' to "Alex"

If 'block' = '1b' or '1C' or '2" change 'Supervisor new' to "Dan"

 

Can anyone help me with the logic to achieve this?

 

1 ACCEPTED SOLUTION

you could edit the code in Advanced Editor. put the basic logic in using the Conditional Column functionality and then edit the code that is generated to add in any additional logic you need.

View solution in original post

4 REPLIES 4
Coriel-11
Resolver II
Resolver II

Try entering this into the box that comes up when you click "Custom Column"

 

if [Area] = 1 then "Alex" else 
if [Block] = "1B" then "Dan" else 
if [Block] = "1C" then "Dan" else
if [Block] = "2" then "Dan" else
[Supervisor]

 

johnt75
Super User
Super User

In power query editor go to the Add Column tab and select Conditional Column. You can put your logic in there.

Anonymous
Not applicable

After playing around with the conditional column function, I do not see how this can be achieved due to the 'Else if' section not supporting 'and' statements.

 

Any ideas?

you could edit the code in Advanced Editor. put the basic logic in using the Conditional Column functionality and then edit the code that is generated to add in any additional logic you need.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.