cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
yuvarajg Member
Member

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

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.
Moderator v-yuezhe-msft
Moderator

Re: Copy the value of a column based on condition

@yuvarajg,

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.
2 REPLIES 2
Super User
Super User

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.
Moderator v-yuezhe-msft
Moderator

Re: Copy the value of a column based on condition

@yuvarajg,

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.