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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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.

View solution in original post

v-yuezhe-msft
Employee
Employee

@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
v-yuezhe-msft
Employee
Employee

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

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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