cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Goku100
Helper I
Helper I

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 IV
Super User IV

@Goku100 , a new column

Switch( True(),

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

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

[Code A]

)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

4 REPLIES 4
amitchandak
Super User IV
Super User IV

@Goku100 , a new column

Switch( True(),

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

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

[Code A]

)



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

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.

 

@Goku100 , 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.



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

@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
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Urdu Hindi D365 Bootcamp 768x460.png

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors