cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CAT6xx
Frequent Visitor

Column return if column value is 0

I looking for a DAX expression or another way to create a "New Column" that returns the value from "Column 2" if "Column 1" value is 0 and value from

"Column 1" if "Column 2" is 0.

 

Any help would be great!

 

Column 1Column 2 New Column
120 12
043 43
430 43
022 22
056 56
540 54
077 77

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

=MAX(Data[Column 1],Data[Column 2])

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Try this calculated column formula

=MAX(Data[Column 1],Data[Column 2])

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
V-pazhen-msft
Community Support
Community Support

@CAT6xx 

Use @az38 's DAX but remove "undefined", because it is text datatype, Column 1 and Column 2 are numerical numbers. I guess you would return an error of variant datatype. 

 

New Column = SWITCH(TRUE(),
[Column 1] = 0, [Column 2],
[Column 2] = 0, [Column 1])

 

Paul Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

az38
Community Champion
Community Champion

Hi @CAT6xx 

try a simple column

Column = SWITCH(TRUE(),
[Column 1] = 0, [Column 2],
[Column 2] = 0, [Column 1],
"Undefined"
)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors