Select Page

What are Expressions?

Flow has a rich set of actions, based on connectors but many a times there is a need for operations like get current date, adding numbers, concatenate strings etc. That’s where expressions come to the rescue. Power Automate leverages the same Workflow Definition Language used by Azure Logic apps. For new users who are unfamiliar with the expression language, there is an inline help experience that shows how to use each expression as they build out their flow.

Expressions are a set of functions that can be used to perform specific actions within a flow.

Examples of actions: Manipulate strings, Working with dates, Converting data types, Perform logical functions, Perform mathematical calculations, Perform complex conditional statements, etc.

Sample expression :
replace (text, oldText, newText)

Sample data :
replace (‘The Old World’, ‘Old’  , ‘New’)

Output : The New World

Expressions can be used in flow actions, conditions and trigger.

Where can Expressions be used?

Actions

Expressions can be used in any flow action.

Conditions

Expressions can be used in any flow condition.

Trigger

Expressions can be used in flow trigger conditions.

Useful to conditionally trigger flows and thereby save flow runs.

Expression Editor

Classic EditorModern Editor
Generally AvailableExperimental Feature
Less space to enter expressionExpression space is large
Switch required to dynamic contentDynamic content available within expression window
Requires user to click button to confirm expressionUpdates the expression on the fly

Best Practices

  • Power Automate reads and processes dates and times in Coordinated Universal Time (UTC).
  • Rename actions with meaningful names (since these names would be used in expressions).
  • Add expression as Notes to actions and conditions (makes it easy to read the underlying expression). •
  • Use Peek Code to check for expression syntax (peek code is your friend).
  • Use the ? for reading optional properties from JSON objects.
  • [] Array notation in JSON objects.
  • When updating expression, make sure to hit the Update button (classic editor).

Download Flow samples with expressions:

Reduce number of variables and Save API Calls – https://github.com/rdorrani/Microsoft-Flow/blob/master/Expressions401-ReducenumberofVariables-SaveAPICalls_20210211210303.zip

Error handling of flows with expressions – https://github.com/rdorrani/Microsoft-Flow/blob/master/Expressions401-ErrorHandling_20210211210406.zip

Calculate number of working days for 2 given dates – Microsoft-Flow/Expressions-CalculateWorkingDaysbasedonagivendaterange_20211018182851.zip at master · rdorrani/Microsoft-Flow (github.com)

Expression to grab the flow run link:

concat('https://us.flow.microsoft.com/manage/environments/', workflow()?['tags']?['environmentName'], '/flows/', workflow()?['name'], '/runs/', workflow()?['run']['name'] )

To learn about flow expressions check out the Expressions Video:


To learn about flow trigger conditions leveraging expressions and thereby saving API calls:

Keep flowing!

Regards,

Reza