Power Automate (WDL) function
if — Power Automate (WDL) function reference
Return a value by condition.
Syntax
wdl
if(expression, valueIfTrue, valueIfFalse)
Examples
wdl
if(greater(variables('n'), 0), 'pos', 'neg')→ One of two values
There is no elseif — nest another if() in the false branch for a third outcome.
wdl
if(equals(item()?['Status'], 'Approved'), 'Green', if(equals(item()?['Status'], 'Rejected'), 'Red', 'Yellow'))
→ "Green" / "Red" / "Yellow"
wdl
if(greater(length(triggerBody()?['Comments']), 0), triggerBody()?['Comments'], 'No comments provided')
→ The comment text, or the fallback string
Common mistakes & gotchas
- if() takes exactly one boolean expression and two branches. Past 3–4 levels of nesting, a Switch action in the flow designer reads far more clearly than nested if() expressions.
- Comparing against an empty string with equals('', ...) instead of checking with empty(...) is a common way to land in the wrong branch when a field is genuinely null rather than an empty string.
Related Workflow Definition Language functions
From Logic & comparison