cancel
Showing results for 
Search instead for 
Did you mean: 
adedapo

Simplifying Complex Expressions with Power Automate Part 1

Power Automate utilizes the workflow definition language used by Azure Logic Apps. Expressions in Power Automate are simple functions that transform and return data. In other words, expressions help you write formulas to manipulate data according to your needs.

Why Use Complex Expressions?

There are several reasons why writing complex expressions in Power Automate is beneficial:

  1. Shaping complex data: Expressions allow you to manipulate and structure data in a way that suits your requirements.
  2. Faster run time: Using expressions for certain tasks and steps can improve the overall speed and efficiency of your workflows.
  3. Reducing API calls: By utilizing expressions, you can minimize the number of API calls required, optimizing resource usage.

Examples of Actions Suited for Expressions

Expressions are particularly useful for the following actions:

  1. Manipulating strings: You can easily manipulate and transform text data.
  2. Working with dates: Expressions facilitate date-related calculations and conversions.
  3. Converting data types: You can convert data from one type to another using expressions.
  4. Performing logical functions: Expressions enable you to perform logical operations and comparisons.
  5. Performing mathematical calculations: Complex calculations can be executed using expressions.
  6. Implementing complex conditional statements: Expressions help you create advanced conditional logic.

Understanding Data Types in Power Automate

To enhance your Power Automate skills, it's important to understand the different data types within the platform.

Power Automate data types are categorized into two groups:

  1. Simple data types: These represent single values, such as texts and numbers. They can be used independently or as part of more complex types. Examples include strings, integers, floats, and booleans.
  2. Complex data types: These types represent more intricate data structures that can consist of simple types or other complex types. Examples include objects and arrays.

Simple Data Types

Simple data types are single values and include:

  • String: A sequence of characters.
  • Integer: A whole number value.
  • Float: A numeric value with a decimal point.
  • Boolean: A value that can be either true or false.

Complex Data Types

Complex data types represent more intricate data structures and include:

  • Object: Contains pairs of properties and values. It can represent an item in a table, with properties analogous to column names and values representing the corresponding row's data. For example: {"ID": 1, "Title": "Row title"} represents an object with two properties: ID (numeric value 1) and Title (string value "Row title").
  • Array: An ordered collection of items of the same data type. Arrays can consist of strings, integers, booleans, objects, or even other arrays.

 

Anatomy of a Function

To be able to write complex expressions, you need to have an in-depth understanding of functions. There are 3 parts to understanding how to use any functions:

Parameters

These are input data that a function may need to work. A function can have zero, one or multiple parameters. The kind of data a function can accept as a parameter is of course determined by the data type. Consider the image below

add_prop.png

The addProperty function expects 3 parameters: an object, a string and a value of any type. (The parameter name is before the colon and the data type is after for each parameter).

Function of the function

To properly use a function, you need to understand what the function is capable of and how it can help you to achieve your goals. Functions are categorized in Power Automate by a general type or types of data that they manipulate. I will provide examples of the most common functions in some of the categories later in this series.

Return type

When a function is done functioning it may return data back to your flow. The data that is returned by a function is also restricted by its type. From the image above, the addProperty function returns an object. With this information, you can pass a function that returns a certain type as a parameter of another function that expects that type. This is called nesting.

Consider the expression below

 

 

 

 

equals(1,1)

 

 

 

 

  • Parameters: 2 parameters of type integer with values 1. While integers are used in this example, equals can compare 2 values of any type; this may not be the case for other functions.
  • Function: compares 2 values of the same type to see if they are equal or not.
  • Return type: returns a value of type Boolean; true if equal, or false if otherwise.

As stated previously, we can pass the return value to a function with at least one parameter with a data type that matches the return type of this function. Nesting will be covered in the next part of this series.

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/