cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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 1 Column 2 New Column 12 0 12 0 43 43 43 0 43 0 22 22 0 56 56 54 0 54 0 77 77

1 ACCEPTED SOLUTION
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
3 REPLIES 3
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
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.

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

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors