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
catpoisoncat
Frequent Visitor

How to create a new column based on the conditions of the other columns?

Hi guys,

 

I am new to Power BI, and come across this situation that I need to create a new column based on conditions of the other 4 columns. I've pasted screenshot of what the columns like down below with my further exaplanaiton.

 

Screenshot 2022-12-20 100657.png

As you can see 4 columns here and I marked then with different colours and with numbers as well.

Screenshot 2022-12-20 101301.png

Here is the condition from SQL server.

 

Bascially, I need to generate a new column (column 5) based on the conditions show in SQL. The conditions in SQL is saying if column 4 cell equals to SCA, then the new column 5 cell should use the value from column 1, and if the column 4 cell equals to OYU, then the new column 5 cell should use the value from column 3, and if the column 4 cell equals to neither SCA nor OYU, then use the the calue from column 2 for the new column 5. And after done all of that, column 1, 2 and 3 needs to be invisible.

 

So I was wondering if I can do this on Power BI?

 

Thanks in advanced.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@catpoisoncat , You can use Switch to create new column

 

column 5 = Switch(True() ,

[Column4] = "SCA", [Column1]

[Column4] ="OYU",[Column3],

[Column 2])

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@catpoisoncat , You can use Switch to create new column

 

column 5 = Switch(True() ,

[Column4] = "SCA", [Column1]

[Column4] ="OYU",[Column3],

[Column 2])

 

Switch-Case statement of #PowerBI: https://www.youtube.com/watch?v=gelJWktlR80&list=PLPaNVDMhUXGaaqV92SBD5X2hk3TMNlHhb&index=56

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.