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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

Copy the value of a column based on condition

i have a following table.

 

column1    Column2

     2                0

     5

     6                0

     12

 

if column2 having null value copy the column1 value. if column2 having 0 value return 0

 

 

expected output

   0

   5

   0

  12

2 ACCEPTED SOLUTIONS
MattAllington
Community Champion
Community Champion

In power query, goto add column, custom column and write a formula (Case sensitive)

 

= if [column2] = null then [column1] else [column2]



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

Anonymous
Not applicable

@Anonymous,

Another method is to create a calcualted column using DAX below.

Column = IF(ISBLANK(YourTable[Column2]),YourTable[column1],YourTable[Column2])

Capture.PNG

Regards,
Lydia

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Anonymous,

Another method is to create a calcualted column using DAX below.

Column = IF(ISBLANK(YourTable[Column2]),YourTable[column1],YourTable[Column2])

Capture.PNG

Regards,
Lydia

MattAllington
Community Champion
Community Champion

In power query, goto add column, custom column and write a formula (Case sensitive)

 

= if [column2] = null then [column1] else [column2]



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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