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
RMDNA
Solution Sage
Solution Sage

If a and b then x else y

Need help with a simple calculation/custom column that I can't seem to figure out.

 

I have a column named "IsWin" with values of "True" or "False", and a column "Status" with a value "Loss", among others.

 

All I need is, if IsWin is false and Status is loss, then TrueLoss, else "NotTrueLoss" for any other combination.

 

However, any number of things I try don't seem to work out. Right now I have:

 

= if(([isWin] = "False") then if ([Status] = "Loss") then "TrueLoss" else "NotTrueLoss" else "Other").

 

This is valid, but just fills all fields with "Other." Any help? I don't feel like this should be hard, but to my knowledge you can't do "if-and-else" statements using the Conditional Column wizard.

 

Thanks.

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

If the conditions get more complicated (like using and or or), then use "Add Custom Column" instead of "Add Conditional Column".

 

If your "IsWin" field has logical values true/false (rather then text "True"/"False"), you can add a custom column with the following formula:

= if not [Iswin] and [Status] = "Loss" then "TrueLoss" else "NotTrueLoss"

 

If you wish, you can replace not [IsWin] by [IsWin] = false (lowercase)

 

If IsWin is text, replace not [IsWin] by IsWin = "False", but mind the case as Power Query is case sensitive.

Specializing in Power Query Formula Language (M)

View solution in original post

1 REPLY 1
MarcelBeug
Community Champion
Community Champion

If the conditions get more complicated (like using and or or), then use "Add Custom Column" instead of "Add Conditional Column".

 

If your "IsWin" field has logical values true/false (rather then text "True"/"False"), you can add a custom column with the following formula:

= if not [Iswin] and [Status] = "Loss" then "TrueLoss" else "NotTrueLoss"

 

If you wish, you can replace not [IsWin] by [IsWin] = false (lowercase)

 

If IsWin is text, replace not [IsWin] by IsWin = "False", but mind the case as Power Query is case sensitive.

Specializing in Power Query Formula Language (M)

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.