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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Creating new column based on NULL values in other columns

Hey,

I am trying to create a new column in Power BI based on certain conditions, please see example data below:

 

Goku100_0-1623667106924.png

 

The conditions for the column I want to create is:

IF [Code A] is NULL then take value from [Code B],

IF [Code B] is NULL then take value from [Code C], 

ELSE use value in [Code A]

 

How do I write this up in Power BI correctly?

Thanks

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , a new column

Switch( True(),

isblank([Code A] ) && isblank([Code B]) , [Code C] ,

isblank([Code A] ),[Code B],

[Code A]

)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , a new column

Switch( True(),

isblank([Code A] ) && isblank([Code B]) , [Code C] ,

isblank([Code A] ),[Code B],

[Code A]

)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Thanks @amitchandak but its not working properly. The values i am getting in the new column is values only from Column A e.g. If column A is NULL and column B is ABC, the new column output is NULL, however I want the output to be ABC.

 

@Anonymous , is it blank or null string

 

Switch( True(),

[Code A] = "NULL"  && [Code B] = "NULL" , [Code C] ,

[Code A] = "NULL" ,[Code B],

[Code A]

)

 

Can you share a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

@amitchandak Yes it was a null string! didnt realise. Edited the above code to make it work with the string, thanks a lot!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.