Forum Discussion
Help with IF DAX
- 6 years ago
Hi daledale,
Yes, you could try to create a calculated column like below to get your result
Column = if(T5[Attribute]="Variance" && T5[Value]>0, 1,2)or you could try to use M code to achieve this goal
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIE4kAQw9BUKVYHScwIJGaAIuaWX5SanFhcApJBkQhLLMpMzEtOBTIRpjjBTTZCFTPCUIbVYCdUg3WBWmIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Node = _t, Category = _t, Attribute = _t, Value = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Node", Int64.Type}, {"Category", type text}, {"Attribute", type text}, {"Value", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Attribute]="Variance" and [Value]>0 then 1 else 2) in #"Added Custom"By the way, what did you mean of "I've tryied splitting the data in different tables also but I'm not able to solve it"? If possible, could you please inform me more detailed information(such as your expected output).
Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi daledale,
Yes, you could try to create a calculated column like below to get your result
Column = if(T5[Attribute]="Variance" && T5[Value]>0, 1,2)
or you could try to use M code to achieve this goal
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXIE4kAQw9BUKVYHScwIJGaAIuaWX5SanFhcApJBkQhLLMpMzEtOBTIRpjjBTTZCFTPCUIbVYCdUg3WBWmIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Node = _t, Category = _t, Attribute = _t, Value = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Node", Int64.Type}, {"Category", type text}, {"Attribute", type text}, {"Value", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [Attribute]="Variance" and [Value]>0 then 1 else 2)
in
#"Added Custom"
By the way, what did you mean of "I've tryied splitting the data in different tables also but I'm not able to solve it"? If possible, could you please inform me more detailed information(such as your expected output).
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks! I've figured it out with your formula.