Control flow tags

Note

Effective October 12, 2022, Power Apps portals is Power Pages. More information: Microsoft Power Pages is now generally available (blog)
We will soon migrate and merge the Power Apps portals documentation with Power Pages documentation.

Control Flow tags determine which block of code should be executed and what content should be rendered based on given conditions. Conditions are built using the available Liquid operators, or just based on the truth or falsehood of a given value.

if

Executes a block of code if a given condition is met.

{% if user.fullname == 'Dave Bowman' %}

Hello, Dave.

{% endif %}

unless

Like if, except it executes a block of code if a given condition isnot met.

{% unless page.title == 'Home' %}

This is not the Home page.

{% endunless %}

elsif/else

Adds more conditions to an if or unless block.

{% if user.fullname == 'Dave Bowman' %}

Hello, Dave.

{% elsif user.fullname == 'John Smith' %}

Hello, Mr. Smith.

{% else %}

Hello, stranger.

{% endif %}

case/when

A switch statement to compare a variable to different values, and execute a different block of code for each value.

{% case user.fullname %}

{% when 'Dave Bowman' %}

Hello, Dave.

{% when 'John Smith' %}

Hello, Mr. Smith.

{% else %}

Hello, stranger.

{% endcase %}

See also

Iteration tags
Variable tags
Template tags
Dataverse table tags