Essential Expressions for Power Automate WorkflowsEssential Expressions for Power Automate Workflows

In the sphere of automation, Microsoft Power Automate offers a robust and adaptable solution for businesses seeking to optimize their processes, dispense with manual tasks, and enhance productivity. At the core of Power Automate reside expressions, which are compact and potent code snippets that empower users to manipulate data, make informed decisions, and create dynamic workflows.

This article aims to explore the most frequently employed and practical expressions used in Power Automate flows, complemented by illustrative examples to elucidate their real-world applications.

1. Concatenate: Concatenate expression allows you to combine strings of text or values. This is particularly useful when constructing dynamic email subjects, file names, or messages.

Example: concat('Invoice_',formatDateTime(utcNow(),'yyyy_MM_dd'))

This expression generates a filename with the prefix “Invoice_” followed by the current date in the format “yyyy_MM_dd”.

2. Condition: The condition expression enables conditional branching within your flows, allowing you to execute different actions based on specified criteria.

Example: if(equals(triggerBody()?['ApprovalStatus'],'Approved'),'Proceed','Review Required')

In this example, the flow checks if the approval status is “Approved”. If true, it proceeds; otherwise, it indicates that a review is required.

3. FormatDateTime: FormatDateTime expression enables you to format dates and times according to your desired format.

Example: formatDateTime(triggerBody()?['Created'],'dd/MM/yyyy')

This expression formats the creation date of a document into the “dd/MM/yyyy” format.

4. AddDays: The AddDays expression allows you to perform date arithmetic by adding or subtracting days from a given date.

Example: addDays(triggerBody()?['StartDate'],7)

Here, the expression adds 7 days to the start date, useful for calculating deadlines or scheduling reminders.

5. Substring: Substring expression extracts a portion of a string based on specified start and end positions.

Example: substring(triggerBody()?['Title'],0,20)

This expression retrieves the first 20 characters of the title field, useful for truncating lengthy text for display purposes.

6. Trim: Trim expression removes leading and trailing spaces from a string.

Example: trim(triggerOutputs()?['body/Title'])

By trimming the title field, this expression ensures consistency and cleanliness in the data.

7. Split: Split expression divides a string into an array of substrings based on a specified delimiter.

Example: split(triggerOutputs()?['body/Emails'],';')

This expression splits a semicolon-separated list of email addresses into individual elements, facilitating further processing.

8. Coalesce: Coalesce expression returns the first non-null value from a list of inputs, useful for handling null values gracefully.

Example: coalesce(triggerBody()?['ManagerEmail'],'No Email')

In case the manager’s email is null, this expression returns “No Email” instead of throwing an error.

9. A method for retrieving fields from related entities for a single record or multiple records

Using Expand Query:

  • This method works best for retrieving data from related entities with a one-to-many (1:N) relationship with your main entity.
  • Within the “List Records” connector for your main entity, utilize the “Expand Query” section.
  • Specify the related entity name followed by ($select=field1,field2), listing the desired fields separated by commas.
  • This retrieves the related entity data alongside your main entity records.

10. An action that returns the first row of a list

The “List rows” action in Power Automate retrieves data, but it returns an array even if there’s only one record. Here’s how to access the value from the first row:

Using an Expression:

  1. Add a “Compose” action after your “List rows” action.
  2. In the Compose action, use an expression to access the first element of the array and then the specific field value. Here’s the format:

Example: first(body(‘List_Rows_Action_Name’)?[‘value’])?[‘Field_Name’]

Mastering these expressions unlocks the full potential of Power Automate, empowering users to create dynamic, intelligent workflows tailored to their specific needs. As you explore and experiment with these expressions, you’ll discover endless possibilities for automating tasks, streamlining processes, and driving efficiency across your organization.

Leave a Reply

Your email address will not be published. Required fields are marked *