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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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