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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Class66Loco
Advocate I
Advocate I

if [column1] = "ABC" and [column2] = "123" then 1 else 0

Hello,

I'm trying to create a custom column that returns 1 or 0 depending on if specific values of two columns are met.

 

My current code below is only returning 0 (FALSE):
= if [Status]= "Responded" and [WithinSLA] = "TRUE" then 1 else 0

 

I'd like to return 1 (TRUE) if there's "Responded" in the Status column and if "TRUE" is in the WithinSLA column.

Thanks for any help.

1 ACCEPTED SOLUTION
Alex87
Solution Sage
Solution Sage

Hello,

Best practice is to add the new column inside power query (copy paste this code inside a new blank query/ advanced editor): 

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkotLsjPS0lNUdJRCgkKdVWK1YlWCkjNS8nMSwcKuTn6BEPEkBVCRWMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Status = _t, WithinSLA = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Status", type text}, {"WithinSLA", type logical}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Status] = "Responded" and [WithinSLA] = true then 1 else 0, type number)
in
    #"Added Custom"

 

 

but if you prefer a DAX calculated column, this should do the work:

 

Custom2 = 
IF(MyTable[Status] = "Responded" && MyTable[WithinSLA] = TRUE(), 1, 0)

 

If it answers your query, please mark my pos as the solution. Thanks!

 

Best regards,

Alex

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!




View solution in original post

1 REPLY 1
Alex87
Solution Sage
Solution Sage

Hello,

Best practice is to add the new column inside power query (copy paste this code inside a new blank query/ advanced editor): 

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkotLsjPS0lNUdJRCgkKdVWK1YlWCkjNS8nMSwcKuTn6BEPEkBVCRWMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Status = _t, WithinSLA = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Status", type text}, {"WithinSLA", type logical}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Status] = "Responded" and [WithinSLA] = true then 1 else 0, type number)
in
    #"Added Custom"

 

 

but if you prefer a DAX calculated column, this should do the work:

 

Custom2 = 
IF(MyTable[Status] = "Responded" && MyTable[WithinSLA] = TRUE(), 1, 0)

 

If it answers your query, please mark my pos as the solution. Thanks!

 

Best regards,

Alex

 




Did I answer your question? Mark my post as a solution!
Appreciate your Like/Kudos

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.