“I’d like to use the if(…) expression but I don’t know how to create the condition, is there some trick in the Power Automate designer?”
Recently I published an article on replacing the ‘Condition’ actions with if(…) expressions to simplify a flow. Instead of a bunch of conditions and repeating actions you can have just a single action with if(…) expressions. But creating the right condition inside if(…) is a bit more complicated than using the standard action. How do you “rewrite” the condition? What should you “type in” as the first parameter of the expression?
Use the ‘Filter array’ action to create the condition
As with the trigger conditions, you can use a small trick and let the designer create the condition for you. Add the ‘Filter array’ action into your flow and recreate the condition you want to replace with the if(…) expression.
Click on ‘Edit in advanced mode’ to transform the condition inside ‘Filter array’ into text.
Remove the @ at the beginning and take the rest, that’s the condition to use as the first parameter in if(…).
In this example to check whether a value is less than 3 it’d look as below.
if(less(outputs('Compose_-_Value'), 3), <ifTrue>, <ifFalse>)
Repeat the same process for all the ‘Condition’ actions you want to replace and build the whole expression step by step.
Summary
It might be a bit confusing when trying to replace the Power Automate ‘Condition’ with the if(…) expression, but it’s not that hard. If you use the workaround with the ‘Filter array’ action you don’t need to write the whole condition manually. Recreate the condition 1:1 in that action, switch to the text mode, remove the @, and the condition is ready. You can even combine multiple conditions together using this approach, just build it slowly, condition after condition.
1 thought on “Create easily the condition for Power Automate if(…) expression”