Power Automate Expressions Cheat Sheet
Quick reference for Power Automate cloud flow expressions — string, date, collection, logical, and conversion functions.
How to Use This Cheat Sheet
Power Automate expressions let you transform data, handle conditions, and manipulate values inside cloud flows. You write them in the expression editor (the fx button) or inline using the @{expression} syntax in dynamic content fields.
Every expression follows the pattern: functionName(parameter1, parameter2, ...). Functions can be nested — the inner function evaluates first.
String Functions
| Function | Syntax | Example | Result |
|---|---|---|---|
| concat | concat(text1, text2, ...) | concat('Hello', ' ', 'World') | Hello World |
| substring | substring(text, startIndex, length) | substring('Power Automate', 6, 8) | Automate |
| replace | replace(text, oldText, newText) | replace('2026-03-29', '-', '/') | 2026/03/29 |
| split | split(text, delimiter) | split('a;b;c', ';') | ["a","b","c"] |
| trim | trim(text) | trim(' hello ') | hello |
| toLower | toLower(text) | toLower('HELLO') | hello |
| toUpper | toUpper(text) | toUpper('hello') | HELLO |
| indexOf | indexOf(text, searchText) | indexOf('Power Automate', 'Auto') | 6 |
| contains | contains(text, searchText) | contains('Power Automate', 'Auto') | true |
| startsWith | startsWith(text, searchText) | startsWith('Power Automate', 'Power') | true |
| endsWith | endsWith(text, searchText) | endsWith('report.pdf', '.pdf') | true |
| length | length(text) | length('Hello') | 5 |
| nthIndexOf | nthIndexOf(text, search, n) | nthIndexOf('a-b-c', '-', 2) | 3 |
| slice | slice(text, startIndex) | slice('Hello World', 6) | World |
| chunk | chunk(text, length) | chunk('abcdef', 2) | ["ab","cd","ef"] |
String Tips
indexOfreturns -1 if the search text is not found — use this for conditional checks.substringthrows an error if startIndex + length exceeds the string length. Guard withmin(length(text), desiredLength).splitreturns an array — access elements withfirst(),last(), or bracket notation in a compose action.
Date and Time Functions
| Function | Syntax | Example | Result |
|---|---|---|---|
| utcNow | utcNow() | utcNow() | 2026-03-29T14:30:00.0000000Z |
| addDays | addDays(timestamp, days, format?) | addDays(utcNow(), 7) | 7 days from now |
| addHours | addHours(timestamp, hours, format?) | addHours(utcNow(), -3) | 3 hours ago |
| addMinutes | addMinutes(timestamp, mins, format?) | addMinutes(utcNow(), 30) | 30 mins from now |
| addSeconds | addSeconds(timestamp, secs) | addSeconds(utcNow(), 90) | 90 secs from now |
| formatDateTime | formatDateTime(timestamp, format) | formatDateTime(utcNow(), 'dd/MM/yyyy') | 29/03/2026 |
| convertFromUtc | convertFromUtc(timestamp, tz, format?) | convertFromUtc(utcNow(), 'GMT Standard Time', 'HH:mm') | 14:30 |
| convertToUtc | convertToUtc(timestamp, tz) | convertToUtc('2026-03-29T10:00', 'Eastern Standard Time') | UTC equivalent |
| ticks | ticks(timestamp) | ticks('2026-01-01') | Tick count (100-ns intervals) |
| dayOfWeek | dayOfWeek(timestamp) | dayOfWeek('2026-03-29') | 0 (Sunday) |
| dayOfMonth | dayOfMonth(timestamp) | dayOfMonth('2026-03-29') | 29 |
| dayOfYear | dayOfYear(timestamp) | dayOfYear('2026-03-29') | 88 |
| startOfDay | startOfDay(timestamp) | startOfDay(utcNow()) | 2026-03-29T00:00:00 |
| startOfMonth | startOfMonth(timestamp) | startOfMonth(utcNow()) | 2026-03-01T00:00:00 |
| startOfHour | startOfHour(timestamp) | startOfHour(utcNow()) | Start of current hour |
Common Date Format Strings
| Token | Meaning | Example |
|---|---|---|
yyyy | 4-digit year | 2026 |
MM | 2-digit month | 03 |
dd | 2-digit day | 29 |
HH | 24-hour hour | 14 |
hh | 12-hour hour | 02 |
mm | Minutes | 30 |
ss | Seconds | 00 |
tt | AM/PM | PM |
dddd | Day name | Sunday |
MMMM | Month name | March |
Calculating Date Differences
Power Automate does not have a single dateDifference function that returns a clean number. Use ticks to calculate differences:
div(sub(ticks(variables('EndDate')), ticks(variables('StartDate'))), 864000000000)
That gives you the number of whole days. The magic number 864000000000 is the number of ticks in one day (10,000,000 ticks/second x 86,400 seconds/day).
For hours, divide by 36000000000. For minutes, divide by 600000000.
Collection Functions
| Function | Syntax | Description |
|---|---|---|
| first | first(collection) | Returns the first element |
| last | last(collection) | Returns the last element |
| length | length(collection) | Returns the count of elements |
| contains | contains(collection, value) | Checks if a value exists in the array |
| empty | empty(collection) | Returns true if the array has no elements |
| union | union(collection1, collection2) | Merges two arrays, removing duplicates |
| intersection | intersection(coll1, coll2) | Returns elements common to both arrays |
| skip | skip(collection, count) | Skips the first N elements |
| take | take(collection, count) | Takes the first N elements |
| join | join(collection, delimiter) | Joins array elements into a string |
| sort | sort(collection) | Sorts array in ascending order |
| reverse | reverse(collection) | Reverses the array order |
Accessing Array Elements
Use bracket notation inside a Compose action or variable:
outputs('Parse_JSON')?['body']?[0]?['name']
The ? operator is the safe navigation operator — it returns null instead of throwing an error when a property does not exist.
Logical Functions
| Function | Syntax | Example | Result |
|---|---|---|---|
| if | if(condition, trueVal, falseVal) | if(equals(1,1), 'yes', 'no') | yes |
| equals | equals(val1, val2) | equals(variables('status'), 'Active') | true / false |
| and | and(expr1, expr2) | and(greater(5,3), less(2,4)) | true |
| or | or(expr1, expr2) | or(equals(x,1), equals(x,2)) | true if either matches |
| not | not(expression) | not(equals(1,2)) | true |
| greater | greater(val1, val2) | greater(10, 5) | true |
| greaterOrEquals | greaterOrEquals(val1, val2) | greaterOrEquals(5, 5) | true |
| less | less(val1, val2) | less(3, 10) | true |
| lessOrEquals | lessOrEquals(val1, val2) | lessOrEquals(5, 5) | true |
| empty | empty(value) | empty('') | true |
| coalesce | coalesce(val1, val2, ...) | coalesce(null, null, 'default') | default |
Nested Conditions
You can nest if expressions, but beyond two levels it becomes unreadable. Use a Switch action or a Compose with a lookup object instead:
if(equals(variables('status'), 'A'), 'Active',
if(equals(variables('status'), 'I'), 'Inactive', 'Unknown'))
Conversion Functions
| Function | Syntax | Description |
|---|---|---|
| int | int(value) | Converts to integer — int('42') returns 42 |
| float | float(value) | Converts to float — float('3.14') returns 3.14 |
| string | string(value) | Converts any value to string |
| bool | bool(value) | Converts to boolean — bool(1) returns true |
| json | json(text) | Parses a JSON string into an object |
| xml | xml(value) | Converts JSON or string to XML |
| base64 | base64(value) | Encodes to Base64 |
| base64ToString | base64ToString(value) | Decodes Base64 to string |
| base64ToBinary | base64ToBinary(value) | Decodes Base64 to binary |
| binary | binary(value) | Converts value to binary |
| decodeBase64 | decodeBase64(value) | Alias for base64ToString |
| decodeUriComponent | decodeUriComponent(text) | Decodes URL-encoded text |
| encodeUriComponent | encodeUriComponent(text) | URL-encodes text |
| array | array(value) | Wraps a single value in an array |
| createArray | createArray(val1, val2, ...) | Creates an array from values |
Common Patterns
Conditional Text in an Email or Message
if(greater(variables('Amount'), 1000), 'High value order', 'Standard order')
Null Handling with Coalesce
When a dynamic content value might be null, wrap it in coalesce to provide a fallback:
coalesce(triggerOutputs()?['body/company'], 'Not specified')
Extracting a File Name from a Path
last(split(variables('FilePath'), '/'))
Getting the Domain from an Email Address
last(split(variables('Email'), '@'))
Formatting a Number with Leading Zeros
To pad a number to 5 digits:
substring(concat('00000', string(variables('OrderNumber'))), sub(length(concat('00000', string(variables('OrderNumber')))), 5))
A cleaner alternative if you have the formatNumber function available:
formatNumber(variables('OrderNumber'), '00000')
Parse JSON and Access Nested Values
After a Parse JSON action named Parse_JSON:
body('Parse_JSON')?['customer']?['address']?['postCode']
Always use the safe navigation operator ? to avoid null reference errors.
Dynamic Content Expressions for Trigger Outputs
triggerOutputs()?['body/value']
triggerBody()?['fieldName']
Check If a String Is a Valid Date
There is no built-in isDate function. A practical workaround is to use formatDateTime inside a Try scope — if it fails, the string is not a valid date.
Working with Time Zones in the UK
convertFromUtc(utcNow(), 'GMT Standard Time', 'dd/MM/yyyy HH:mm')
Note: GMT Standard Time in Windows time zone IDs automatically handles British Summer Time (BST) switching.
Removing HTML Tags from Text
replace(replace(replace(body('Get_item')?['Description'], '<br>', ' '), '<[^>]+>', ''), ' ', ' ')
For robust HTML stripping, use the built-in Html to text action instead of expressions.
Expression Error Reference
| Error | Likely Cause | Fix |
|---|---|---|
InvalidTemplate | Syntax error in expression | Check brackets, quotes, commas |
Unable to process template language | Missing or extra parameters | Verify function signature |
The template function is not valid | Misspelt function name | Check capitalisation (camelCase) |
Cannot convert value to type | Wrong data type passed | Use conversion functions first |
Index was out of range | Array/string index too large | Guard with length() check |
Quick Reference: Expression Editor Shortcuts
- Type
@in a text field to switch between dynamic content and expression mode. - Use the Expression tab and type the function name — IntelliSense will suggest completions.
- Click a dynamic content token while in the expression editor to insert its reference path.
- Test expressions in a Compose action before using them in complex actions — it makes debugging far easier.