Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Expression.Evaluate throws an exception error when the reference to the current row is used together with native function, like [Text.Contains = Text.Contains, _=_]
let
Conditions = let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WykxT0lGKDkvNS8kvilWwVYhRCk7MLchJNYxRAkqUZKTmASmIkFKsDky9f1Fmun9BalFiSX6RZwpEX1JReoySQmJeikJ0cGVxSWouRNgxANmkoNTi0pwSQySj0NUq5BehGhDgj2yAY0CAP0J3SGpFiZ5zfl5JYmZesQbMGzoKcG8YxShpYvojFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Hypothesis = _t, Condition = _t, Conclusion = _t, Result = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Hypothesis", type text}, {"Condition", type text}, {"Conclusion", type text}, {"Result", type text}})
in
#"Changed Type",
ListOfConditions = Table.ToRows(Conditions),
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQpOzC3ISTUCsYyBhG9inlKsTrSSEVwKpCg9H0i4FwWBpYzhUiBWUlE6kHQMAEuZwKVArKTUVKhULAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Vendor = _t, OrigOperatorId = _t, System = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Vendor", type text}, {"OrigOperatorId", type text}, {"System", type text}}),
Evaluate = Table.AddColumn(
#"Changed Type",
"Custom",
each List.First(
List.Transform(
ListOfConditions,
(l) => Expression.Evaluate(
" if " & l{1} & " then """ & l{3} & """ else null",
[Text.Contains = Text.Contains, _=_]
)
)
)
)
in
Evaluate
For more details, please check this thread: https://community.powerbi.com/t5/Desktop/Power-Query-Configurable-Dynamic-If-Statement/td-p/1288482
Current workaround is OK so far.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.