Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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.
Solved! Go to Solution.
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
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
User | Count |
---|---|
97 | |
88 | |
76 | |
70 | |
63 |
User | Count |
---|---|
112 | |
96 | |
95 | |
67 | |
65 |