cancel
Showing results for 
Search instead for 
Did you mean: 
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

Accepted Solutions

Re: Copy the value of a column based on condition

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

 

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



* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

Microsoft
Microsoft

Re: Copy the value of a column based on condition

@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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2

Re: Copy the value of a column based on condition

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

 

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



* Matt is a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

Microsoft
Microsoft

Re: Copy the value of a column based on condition

@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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors