September 26, 2025

SamTech 365 – Samir Daoudi Technical Blog

PowerPlatform, Power Apps, Power Automate, PVA, SharePoint, C#, .Net, SQL, Azure News, Tips ….etc

A Guide to Power Automate Functions

Master Power Automate functions with this complete guide. Learn key syntax, see practical examples, and elevate your workflow automation skills.

If you're just getting started with Power Automate, you might think of it as a tool that just moves data from point A to point B. But to really unlock its potential, you need to get comfortable with Power Automate functions.

Think of functions as the brains behind the operation. They are the core building blocks of the Power Automate expression language, letting you go far beyond simple, static workflows. They’re what transform a basic flow into a dynamic, intelligent automation.

The Foundation of Dynamic Automation

So, what does this mean in practice? Instead of just passing information along, functions let you actively do things with that data right inside your flow. You can format dates on the fly, stitch pieces of text together, check if a certain condition is true, or run calculations.

The expression language itself, where all these functions live, is based on the Workflow Definition Language that Microsoft uses across its services. Getting a handle on this language is the key to building automations that are not just more powerful, but also smarter and more robust.

When you start using expressions, you'll see a few immediate benefits:

  • Enhanced Data Handling: You can clean up, reformat, and restructure data coming in from different apps to make sure it's perfect for the next step in your flow.
  • Reduced Complexity: Instead of adding five or six separate action steps to manipulate some text, you can often do it all in a single, clean expression. It keeps your flows lean.
  • Intelligent Decision-Making: With logical functions, you can build conditional paths that let your flow react differently based on the data it receives. It’s how you make your automation truly adaptive.

You can see how the platform's capabilities have grown over time, giving developers more and more powerful tools to work with.

Image

This trend makes it clear: the platform is constantly evolving to give us more flexible and sophisticated ways to build our automations.

The Growing Importance of Automation Skills

Knowing how to effectively use Power Automate functions isn't just a "nice-to-have" skill anymore—it's becoming essential. Power Automate is a major player in the Robotic Process Automation (RPA) market, and that entire industry is exploding.

The market size shot up from $1.23 billion in 2020 to $3.17 billion in 2022, and it's projected to blast past $7 billion by 2025. This isn't just a small uptick; it's a massive industry-wide shift toward automation. Mastering these skills puts you right in the center of that growth. For a deeper dive, it's worth checking out some of the broader robotic process automation statistics to see just how fast this space is moving.

Essential String and Collection Functions

Image

When you're building flows, you'll constantly find yourself working with text (strings) and lists of items (collections or arrays). It's just the nature of the beast. To handle these, Power Automate gives you a solid set of functions designed specifically for these data types. Getting comfortable with these essential power automate functions is a must for everyday tasks like parsing data from an API, putting together dynamic emails, or looping through items from a SharePoint list.

Let's be honest, wrangling text and arrays is a huge part of automation. In my experience, a good chunk of development time can get eaten up by just preparing and manipulating data. Using the right function from the start makes your flows much cleaner, more efficient, and way easier to troubleshoot down the road. Think of this section as your go-to reference for the string and collection functions you'll be using constantly.

Mastering String Functions for Text Manipulation

String functions are your best friends for slicing, dicing, and rebuilding any text-based data inside a flow. Whether you need to pull a name out of an email subject or construct a custom notification, these functions are indispensable. Let's walk through some of the most critical ones with practical examples. For a full rundown, you can always check out the official Microsoft function reference.

concat()

This one is simple but powerful. It just joins two or more strings together into a single string. It’s perfect for creating dynamic file names or custom messages.

  • Syntax: concat('<text1>', '<text2>', ...)
  • Example: Let's say you want to create a personalized welcome message. You can combine a fixed string with a user's name from your flow's trigger.
    concat('Hello, ', triggerBody()?['userName'], '!')
    If the userName variable holds "Alex," the output is "Hello, Alex!".

substring()

Use substring() when you need to grab just a piece of a string. You tell it where to start (the index) and how many characters you want.

  • Syntax: substring('<text>', <startIndex>, <length>)
  • Example: Imagine you need to pull out the core number from an order ID like "ORD-12345-ABC".
    substring('ORD-12345-ABC', 4, 5)
    This expression returns "12345". Remember, the index starts at 0.

replace()

Just like it sounds, this function finds a piece of text and swaps it out with something else. It's incredibly useful for cleaning up data or enforcing a standard format.

  • Syntax: replace('<text>', '<oldText>', '<newText>')
  • Example: To get rid of dashes in a product code and replace them with spaces:
    replace('PN-001-A', '-', ' ')
    The result will be "PN 001 A".

split()

The split() function is a lifesaver. It takes a single string and chops it up into an array of smaller strings, using whatever separator you define.

  • Syntax: split('<text>', '<separator>')
  • Example: If you have a comma-separated list of tags and need to turn it into a proper array:
    split('automation,power platform,sharepoint', ',')
    This gives you the array ["automation", "power platform", "sharepoint"].

Working with Collection Functions

Collections (or arrays) are just lists of items. You'll run into them all the time with actions like SharePoint's "Get items" or Dataverse's "List rows". These functions are your toolkit for managing those lists.

  • length(): Super simple—it just gives you the number of items in an array. I use this constantly to check if a list is empty before trying to process it.
  • first() / last(): These do exactly what you'd expect: they grab the very first or very last item from an array. This is great for getting the newest entry from a sorted list.
  • union(): This function takes two arrays, mashes them together, and gets rid of any duplicates. You're left with a single array of unique values.

Pro Tip: You can get pretty creative by combining math and collection functions. For instance, to pick a random item from an array, you can use rand() to generate a random index number. If you want to see how that works in practice, check out our guide on how to generate a random number in Power Automate.

These functions are really the building blocks for handling data in your automations. Once you get proficient with them, you'll find you can solve almost any data manipulation puzzle that comes your way.

Using Logical and Conversion Functions

Image

While string and collection functions are great for manipulating data, it’s the logical and conversion functions that give your workflows real intelligence. These power automate functions are the key to building decision-making paths and making sure your data is in the right format, which prevents errors and makes your automations far more resilient.

Think of logical functions as the forks in the road for your flow. They check conditions and steer the automation down different branches based on whether something is true or false. Conversion functions, on the other hand, are like universal translators—they ensure data coming from one system can actually be understood by another.

Building Conditional Paths With Logical Functions

Logical functions are the bedrock of any truly dynamic workflow. They let you build conditions that control how a flow runs. For example, you might only approve an expense if it's below a certain amount or send a follow-up email only if a task is overdue. These are the kinds of smart automations that save serious time.

Here are the core logical functions you’ll find yourself using constantly:

  • if(): This is your classic conditional statement. It checks if something is true and returns one value if it is, and a different one if it’s false. Simple but powerful.
  • equals(): A straightforward comparison to see if two values are identical. It’s the backbone of most conditional checks you'll build.
  • and(): This function takes multiple conditions and only returns true if all of them are met. It's perfect for complex validations where several criteria must be satisfied.
  • or(): Unlike and(), the or() function checks multiple conditions and returns true if at least one of them is true.

Let’s look at a real-world example. Imagine you need to check if a new purchase order is both over $500 and from the "High-Value" department before flagging it for special approval.

You can nest if() with and() to handle this:
if(and(greater(outputs('Get_Order_Details')?['body/totalAmount'], 500), equals(outputs('Get_Order_Details')?['body/department'], 'High-Value')), 'Requires_Special_Approval', 'Standard_Approval')

This single expression cleanly manages what could otherwise be a messy, multi-step validation.

Ensuring Data Integrity With Conversion Functions

Honestly, one of the most common reasons a flow fails is a data type mismatch. This is what happens when you try to use a piece of text (a string) as a number, or a number as a date. Conversion functions are your best defense against these kinds of errors, letting you explicitly change a value's data type.

When you're automating business tasks—where studies show up to 45% of activities are automatable—ensuring data flows correctly between systems is non-negotiable.

Here are a few key conversion functions:

  • int(): Turns a string value into an integer (a whole number).
  • string(): Converts just about anything, like a number or date, into a simple string of text.
  • formatDateTime(): A super useful function for taking a date string and reformatting it exactly how you need it.

For instance, if an API response gives you a price as the text "199.99", you can't use it in a math calculation. You first have to convert it using float('199.99'). This is where these functions become indispensable, especially when you're connecting different services using the huge library of available Power Automate connectors.

Important Takeaway: My advice? Always assume data coming from an external source might be in the wrong format. Be proactive and use conversion functions to clean and format data right when it enters your flow. This simple habit will save you from countless runtime errors down the line.

Here’s a quick reference table I put together for common data conversion scenarios you'll likely run into.

Common Data Type Conversions in Power Automate

This table is a handy cheat sheet for figuring out which function you need to flip data from one type to another.

Conversion Goal Input Data Type Required Function Example Use Case
Text to Whole Number String int() Converting a quantity from a form input for a calculation.
Number to Text Integer/Float string() Appending a calculated total to a text-based email summary.
Text to Decimal Number String float() Converting a product price from an API response for an invoice.
Standard Date to Custom Format DateTime formatDateTime() Formatting utcNow() into 'MM/dd/yyyy' for a report title.
Text to Boolean (true/false) String bool() Converting "true" from a query parameter into a logical value.

Getting a good handle on both logical and conversion power automate functions is a huge step toward building sophisticated and reliable automations that can handle the messy, real-world data you'll encounter every day.

Applying Math and DateTime Functions

Image

While a ton of automations are about shuffling text and lists around, many real-world business processes are built on numbers and time. If you're calculating invoice totals, generating unique IDs, or chasing project deadlines, you absolutely have to get comfortable with the Math and DateTime power automate functions.

These functions give you the precision you need to handle quantitative and time-based data correctly. Think about it: miscalculating a due date or an invoice total isn't just a small hiccup; it can have real financial and operational blowback. Nailing these automations is a huge win for efficiency, with some companies seeing returns on investment between 30% and 200% in just the first year of using tools like Power Automate.

Performing Numerical Calculations With Math Functions

Math functions are the workhorses for any flow that has to crunch numbers. They're pretty straightforward, but they're the foundation for everything from financial calculations and inventory management to data analysis inside your automations. For a complete deep dive, Microsoft has a great reference for all mathematical functions in Power Automate.

Here are a few of the most common ones you'll find yourself using all the time:

  • add(): The simplest one—it just calculates the sum of two numbers. This is your go-to for totaling up line items on a purchase order.
  • sub(): Finds the difference between two numbers. It’s essential for things like calculating discounts or figuring out a remaining balance.
  • div(): Divides one number by another, which comes in handy for calculating averages or splitting costs evenly.
  • rand(): Generates a random integer within a range you specify. This is perfect for creating unique reference numbers or picking random samples from a list.

Example Scenario: Calculating an Invoice Total

Let's imagine you have a flow that’s processing invoices as they come in. You need to calculate the final amount by adding a subtotal and tax, and then subtracting a discount.

You could build an expression that looks something like this:
sub(add(outputs('Get_Invoice_Details')?['subtotal'], outputs('Get_Invoice_Details')?['tax']), outputs('Get_Invoice_Details')?['discount'])

This nested expression is a clean way to do it. It first adds the subtotal and tax together, and then immediately subtracts the discount from that sum. You get the final invoice total in a single, efficient step.

Managing Time With DateTime Functions

Dealing with dates and times can be a massive headache in any kind of development, but thankfully, Power Automate gives us a solid set of functions to make it easier. These are absolutely critical for scheduling tasks, building reports, and managing any process that's time-sensitive.

A key thing to remember is that all DateTime functions in Power Automate work with dates in the Universal Time Coordinated (UTC) format. This is a lifesaver, as it prevents all sorts of time zone errors when your flows are interacting with global services or users in different parts of the world.

Key DateTime Functions for Your Flows

  • utcNow(): This function is your starting point for almost any time-based logic. It returns the current date and time in UTC format, perfect for timestamping a record the moment it's created.
  • addDays(): Adds a specific number of days to a timestamp. You'll also find its siblings—addHours(), addMinutes(), and addSeconds()—for more precise control. It’s ideal for calculating future due dates.
  • formatDateTime(): This one is all about presentation. It converts a date string into a specific, human-readable format, which is incredibly useful for putting friendly dates in emails, reports, or file names.

Example Scenario: Setting a Project Deadline

Let's say a new project is created in your system. You need a flow to automatically set a review deadline for 14 days from today and then format it nicely for a notification email.

  1. Calculate the Deadline: First, you’ll grab the current date and time and add 14 days to it.
    addDays(utcNow(), 14)
  2. Format for Readability: That result is a machine-readable timestamp, not something you'd want to email to a project manager. So, you'll wrap it in another function to make it look good.
    formatDateTime(addDays(utcNow(), 14), 'dddd, MMMM dd, yyyy')

This would turn the date into a clean format like "Friday, October 25, 2024". By stringing these functions together, you can reliably handle time-based rules, making sure your automations stay on schedule and communicate clearly.

Advanced Function Patterns and Best Practices

Once you get comfortable with individual Power Automate functions, the real magic begins when you start combining them. This is where you can solve genuinely complex problems with clean, efficient expressions and build workflows that are both powerful and easy to maintain.

One of the most useful techniques you'll learn is nesting functions. This is simply where the output of one function becomes the input for another. It allows you to perform several data transformation steps all at once, which keeps your flow design lean and cuts down on unnecessary actions.

Combining Functions for Complex Logic

Let's say you get a product code formatted as "SKU-abc-123". Your target system, however, needs it in uppercase and without the "SKU-" prefix. Instead of using separate "Compose" actions for each step, you can chain functions together in a single expression.

A nested expression like toUpper(substring('SKU-abc-123', 4)) gets the job done in one go. The substring() function runs first, pulling out "abc-123". That result is then immediately fed into the toUpper() function, which converts it to "ABC-123". This is far more efficient than creating and managing intermediate variables.

This screen from Microsoft's own Power Fx documentation shows a similar concept, illustrating how these low-code formulas can handle complex logic in a way that’s still quite readable.

The real power comes from assembling simple, reliable building blocks into sophisticated instructions. That’s the core principle behind mastering these advanced patterns.

Best Practices for Clean and Efficient Expressions

Writing a complex expression that works is one thing. Writing it well is another skill entirely. Following a few best practices will ensure your flows aren't just powerful, but also readable, easy to debug, and performant down the line.

  • Use Variables for Very Complex Logic: If an expression becomes a tangled mess, don't be afraid to break it down. Store an intermediate result in a variable. This makes the final expression cleaner and, more importantly, lets you check the variable's value during a flow run to pinpoint any issues.
  • Comment Your Complex Expressions: Power Automate lets you add a note to any action. Use it! A quick comment explaining what a complicated expression does will be a lifesaver for you or your colleagues months later.
  • Optimize Your API Calls: Always try to handle data manipulation within the flow itself rather than making excessive calls to external services. A classic example is using a filter query directly in SharePoint's "Get items" action instead of pulling every single item and then filtering inside the flow. For a deep dive on this, check out our guide on mastering the Power Automate filter query.

The adoption of these kinds of advanced automation techniques is accelerating. In Switzerland, for example, a remarkable 52% of organizations already use AI agents to automate entire business processes, putting them ahead of global and European averages. This shows a mature understanding of how tools like Power Automate can fundamentally change workflows. It's a trend that's only growing, with 80% of Swiss leaders saying 2025 will be a pivotal year for rethinking their AI strategy. You can discover more about these global AI adoption trends and their strategic implications.

No matter how well you know Power Automate functions, you're going to run into expression errors. It just happens. Getting good at debugging them quickly is what separates a good flow builder from a great one. This section is all about how to spot and fix the most common errors you’ll bump into.

When a flow fails because of a bad expression, you'll usually see a red-highlighted action and a message like 'Invalid expression'. These messages can be a bit cryptic, but they're your starting point. In my experience, most of these failures boil down to just three things: data types that don't match, simple syntax mistakes, or trying to use data that isn’t there (what we call a null reference).

Decoding Common Error Messages

The first step to fixing an error is actually understanding what it's trying to tell you. Let's walk through the usual suspects.

  • 'Invalid expression': This is the most generic syntax error. It almost always means you've got a missing comma, an extra parenthesis, or you forgot to wrap your text in single quotes. The first thing I do is scan my expression for matching pairs of () and make sure all my text strings are enclosed properly, 'like this'.
  • Data Type Mismatches: You'll see this when you try to do something like use the add() function on two pieces of text instead of two numbers. Power Automate is strict about this. To get around it, you have to explicitly convert your data using functions like int() or float() before you try to do any math on it.
  • Null Reference Issues: If you see an error like "Unable to process template language expressions… property 'propertyName' cannot be selected," it's a dead giveaway. Your flow tried to grab a piece of data that was either empty or didn't exist at all. You can head this off at the pass by using the coalesce() function to give it a backup value, or by using the question mark operator ?. For example, triggerBody()?['optionalField'] is a lifesaver—it returns a null value instead of crashing the entire flow if that field is missing.

Here's a pro tip that will save you a ton of headaches: if you're about to use dynamic content from a step that might not always run (like an optional field in a form), add a Condition step first. Just check if the data exists. It's a tiny bit of extra work that prevents so many failures down the line.

Power Automate Functions Cheat Sheet

When you're in the middle of building or fixing a flow, you don't always have time to dig through documentation. I put together this quick cheat sheet to cover the functions I use most often. It’s a great starting point for troubleshooting.

Function Category Purpose Example Syntax
concat() String Joins multiple strings together. concat('A', 'B')
split() String Breaks a string into an array. split('a,b,c', ',')
if() Logical Returns a value based on a condition. if(equals(x, y), 'Yes', 'No')
int() Conversion Converts a string to an integer. int('123')
addDays() DateTime Adds days to a timestamp. addDays(utcNow(), 5)
coalesce() Collection Returns the first non-null value. coalesce(item, 'default')

Of course, this is just the tip of the iceberg. For a complete list of every function available, your best bet is to check the official Microsoft function reference documentation.

Frequently Asked Questions

When you get deep into building flows, you run into the same handful of tricky questions over and over. This isn't just about syntax; it's about the practical, real-world problems that can trip you up. Here are some of the most common ones I see, along with the straight answers to keep your automations running smoothly.

How Do I Handle Null or Empty Values in Expressions?

This is easily the #1 cause of flow failures. You try to use a piece of data that isn't there, and the whole thing comes crashing down. The best way to prevent this is to get comfortable with the coalesce() function. Think of it as a safety net; it gives you a fallback value if the one you're looking for is null.

For instance, this expression is a lifesaver: coalesce(triggerBody()?['optionalField'], 'Default Value').

If optionalField has a value, the expression returns it. But if it's missing or null, the expression returns 'Default Value' instead of throwing an error. Building this check into your expressions is a simple habit that makes your flows far more resilient.

What Is the Difference Between @ and ? in Expressions?

Both are tiny symbols that do a ton of work, but they have very different jobs.

  • @: This symbol is your signal to Power Automate that what follows is an expression to be evaluated, not just plain text. When you write @utcNow(), the @ tells the engine to run the utcNow() function instead of just printing the letters "utcNow()." Simple as that.
  • ?: This is the null-conditional operator, and it's your best friend for safely digging into nested objects. If you write triggerBody()?['user']?['email'], it won't fail if the user object doesn't exist. Instead, it will just return a null value, which you can then handle gracefully.

Can I Create My Own Custom Functions?

The short answer is no, not in the traditional sense of defining a reusable function directly in the expression language. But you can absolutely achieve the same result using a powerful pattern: child flows.

A child flow is a separate, standalone flow that you can call from your main (parent) flow. You can pass inputs to it, have it perform a specific set of actions, and then return an output back to the parent. This lets you build modular, reusable blocks of logic that act just like a custom function. It’s the go-to method for keeping complex automations clean and organized.

For the definitive, most up-to-date guide on every built-in function, your best bet is always the official Microsoft Workflow Definition Language function reference. It's the source of truth, packed with detailed syntax and examples.


At SamTech 365, we focus on practical tutorials and real-world scenarios to help you get the most out of the Power Platform. Explore our guides to start building smarter, more efficient automations today.
https://www.samtech365.com

Discover more from SamTech 365 - Samir Daoudi Technical Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading