Skip to content

Power Automate Functions: Cheat Sheet and Best Practices

Power Automate functions cheat sheet: expression functions by category with examples, the div() integer-division gotcha, and best practices.

Citizen Development Academy Updated 5 min read
Power Automate Functions: Cheat Sheet and Best Practices
In this article · 15 sections

Functions are the expressions that do the real work inside a Power Automate flow: joining text, doing math, comparing values, reshaping dates, and pulling apart arrays. Learn a couple of dozen of them and most “how do I get this value into the right shape” problems stop being hard. This guide is the working reference: what a function is, a cheat sheet grouped by job, the one gotcha that catches everyone, and the habits that keep expressions readable.

Updated June 2026 against Microsoft’s reference guide to expression functions, which covers both Power Automate and Azure Logic Apps. These expression functions apply to Power Automate cloud flows; Power Automate Desktop (RPA) uses a different model.

Function, action, trigger: what is the difference

These three words get mixed up, so it is worth being precise.

  • A trigger is the event that starts a flow: a new email, a new SharePoint item, a scheduled time. Every flow has exactly one.
  • An action is a step the flow runs: send an email, create a row, post to Teams, or the workhorse Compose action that just holds a value.
  • A function is an expression you write inside an action or a condition to transform data, for example concat(first, ' ', last) or length(body). Functions do not run on their own; they shape the inputs and outputs of actions.

So a flow is triggers and actions wired together, and functions are the small expressions that make the data flow between them correct.

The Power Automate function cheat sheet

You write these in the expression editor (the fx tab when you click into a field). Here are the ones worth memorizing, grouped by what they do. The full list lives in Microsoft’s functions reference.

String functions

FunctionWhat it doesExample
concat(a, b, ...)Joins values into one stringconcat('Hi ', name)
length(text)Number of characters (or array items)length('hello') returns 5
substring(text, start, len)Pulls part of a string (start is 0-based)substring('ABCDE', 1, 2) returns 'BC'
replace(text, old, new)Swaps textreplace(phone, '-', '')
split(text, sep)Breaks a string into an arraysplit('a,b,c', ',')
toLower(text) / toUpper(text)Changes casetoLower(email)
trim(text)Removes leading and trailing spacestrim(input)
startsWith(text, value) / endsWith(text, value)Tests the ends of a stringendsWith(file, '.pdf')

Math functions

FunctionWhat it doesExample
add(a, b) / sub(a, b)Add or subtractadd(price, tax)
mul(a, b)Multiplymul(qty, price)
div(a, b)Divide (see the gotcha below)div(total, count)
mod(a, b)Remaindermod(n, 2) returns 0 for even
min(...) / max(...)Lowest or highestmax(1, 2, 3) returns 3

Logical and comparison functions

FunctionWhat it doesExample
equals(a, b)True if equalequals(status, 'Open')
greater(a, b) / less(a, b)Numeric or string comparisongreater(amount, 1000)
and(...) / or(...) / not(x)Combine conditionsand(equals(a,1), greater(b,2))
if(condition, yes, no)Returns one value or the otherif(greater(n,0), 'positive', 'not')
coalesce(a, b, ...)First non-null valuecoalesce(nickname, firstName)

Date and collection functions

FunctionWhat it doesExample
utcNow()Current date and timeutcNow()
formatDateTime(date, fmt)Formats a date (see the formatDateTime guide)formatDateTime(utcNow(), 'yyyy-MM-dd')
addDays(date, n)Shifts a dateaddDays(utcNow(), 7)
first(coll) / last(coll)First or last itemfirst(items)
contains(coll, value)Membership testcontains(tags, 'urgent')
join(array, sep)Array to stringjoin(emails, '; ')

The div gotcha everyone hits

div() does not always return a decimal. When both numbers are integers, it returns the integer quotient and drops the remainder:

div(10, 5)   returns 2
div(11, 5)   returns 2     (not 2.2)

To get a decimal result, make at least one operand a float:

div(11, 5.0)   returns 2.2
div(11.0, 5)   returns 2.2

This is one of the most common math surprises in Power Automate. If a percentage or average comes out as a whole number when you expected decimals, an integer div() is almost always why. Use a float operand to get the full decimal, or mod() if you want the remainder.

A worked example with Compose

Power Automate has no user-defined functions the way a programming language does. What people mean by “build a function” is usually: hold an expression in a Compose action so you can reuse and inspect its output. The pattern is short.

  1. Add a Compose action where you need the value.
  2. Click into the Inputs field, open the fx expression editor, and write your expression, for example concat(triggerBody()?['FirstName'], ' ', triggerBody()?['LastName']).
  3. Reference that Compose output (outputs('Compose')) in later actions instead of repeating the expression.

Compose is ideal here because it does nothing but evaluate and store the value, which makes it easy to see exactly what an expression produced when you open the run history.

Best practices that keep expressions sane

  • Name your actions. Rename Compose and other steps to what they hold (Compose full name), so later references read clearly instead of Compose 7.
  • Prefer dynamic content over hardcoded values so a flow works across inputs, not just the one you tested.
  • Watch your types. A frequent error is passing a string where a function expects a number. Use int(), float(), or string() to convert deliberately.
  • Use a condition action for booleans. A logical function like equals() returns true or false; put it in a Condition (or a trigger condition) to branch, rather than burying the logic.
  • Use endsWith(), not contains(), to test a file extension. contains('report.pdf.txt', '.pdf') is true but wrong; endsWith(name, '.pdf') is what you mean. These comparisons are case-sensitive, so wrap both sides in toLower() when case can vary: endsWith(toLower(name), '.pdf').
  • Break complex expressions into steps. Several small Compose actions are easier to debug than one nested expression three levels deep.

How to test an expression

The fastest loop is to isolate the expression in a Compose action, run the flow once with the Test button (manual trigger), then open the run history and click the Compose step to see its exact output. If it is wrong, you can see the inputs it received and fix the expression without touching the rest of the flow. Repeat until the output is right, then wire it into the downstream actions.

Frequently asked questions

Where do I write functions in Power Automate?

In the expression editor: click into almost any action field, then open the fx (Expression) tab and type the function. The editor lists available functions and flags syntax errors as you type.

Why does my division return a whole number?

Because div() returns an integer when both inputs are integers, dropping the remainder. Make one operand a float (div(11, 5.0)) to get a decimal, or use mod() if you want the remainder.

Can I create my own custom function in Power Automate?

Not as a reusable function in a cloud flow. You build expressions inline (often parked in a Compose action), and for genuinely shared logic you use a child flow or an Azure Function called from the flow.

Are these functions the same in Azure Logic Apps?

Yes. Both Power Automate and Azure Logic Apps use the same Workflow Definition Language expression functions, which is why Microsoft documents them in one shared reference.

If you want to go from copy-pasting expressions to designing flows with confidence, our Power Automate training walks through expressions, data operations, and error handling end to end.

Stay in the loop

Get new posts delivered to your inbox. No spam, unsubscribe anytime.

Related articles