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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.