Power Automate Expressions Cookbook

Ready-to-use expressions and code snippets. Copy and paste directly into your Power Automate flows.

Copy & Paste

All expressions are ready to copy and paste directly into your flows.

Well Explained

Each expression includes an explanation of what it does and when to use it.

Organized by Category

Find expressions easily with our category-based organization.

Tested & Working

All expressions are tested and verified to work in Power Automate.

Go to top

String Functions

Concatenate strings

Join two or more strings together.

concat('Hello', ' ', 'World')

Result: Hello World

Get string length

Count the number of characters in a string.

length('Power Automate')

Result: 14

Extract substring

Get a portion of a string starting at a specific position.

substring('Power Automate', 0, 5)

Result: Power

Convert to uppercase

Transform all characters to uppercase.

toUpper('power automate')

Result: POWER AUTOMATE

Convert to lowercase

Transform all characters to lowercase.

toLower('POWER AUTOMATE')

Result: power automate

Replace text

Replace occurrences of a substring with another string.

replace('Hello World', 'World', 'Power Automate')

Result: Hello Power Automate

Trim whitespace

Remove leading and trailing whitespace from a string.

trim('  Power Automate  ')

Result: Power Automate

Split string into array

Split a string by a delimiter into an array.

split('apple,banana,cherry', ',')

Result: ["apple","banana","cherry"]

Date Functions

Get current date and time (UTC)

Get the current UTC timestamp.

utcNow()

Result: 2025-12-31T10:30:00.0000000Z

Add days to date

Add a specified number of days to a date.

addDays(utcNow(), 7)

Result: Date 7 days from now

Add hours to date

Add a specified number of hours to a date.

addHours(utcNow(), 2)

Result: Time 2 hours from now

Format date

Convert a date to a specific format.

formatDateTime(utcNow(), 'yyyy-MM-dd')

Result: 2025-12-31

Get day of week

Get the day of the week (0=Sunday, 6=Saturday).

dayOfWeek(utcNow())

Result: 2 (Tuesday)

Convert timezone

Convert a date from UTC to a specific timezone.

convertTimeZone(utcNow(), 'UTC', 'Eastern Standard Time')

Result: Date in Eastern time

Get start of month

Get the first day of the current month.

startOfMonth(utcNow())

Result: 2025-12-01T00:00:00.0000000Z

Array Functions

Get first item

Get the first element of an array.

first(createArray('a', 'b', 'c'))

Result: a

Get last item

Get the last element of an array.

last(createArray('a', 'b', 'c'))

Result: c

Get array length

Count the number of items in an array.

length(createArray('a', 'b', 'c'))

Result: 3

Check if array contains item

Check if an array contains a specific value.

contains(createArray('a', 'b', 'c'), 'b')

Result: true

Join array to string

Combine array elements into a single string with a separator.

join(createArray('a', 'b', 'c'), ', ')

Result: a, b, c

Get unique items

Remove duplicates from an array.

union(createArray('a', 'b', 'a'), createArray())

Result: ["a","b"]

Logical Functions

If condition

Return different values based on a condition.

if(equals(1, 1), 'Yes', 'No')

Result: Yes

Check equality

Check if two values are equal.

equals('hello', 'hello')

Result: true

Check if empty

Check if a value is empty or null.

empty('')

Result: true

Coalesce (first non-null)

Return the first non-null value from a list.

coalesce(null, '', 'default')

Result: default

AND operation

Check if all conditions are true.

and(equals(1,1), greater(5,3))

Result: true

OR operation

Check if any condition is true.

or(equals(1,2), greater(5,3))

Result: true

Math Functions

Add numbers

Add two or more numbers together.

add(10, 5)

Result: 15

Subtract numbers

Subtract one number from another.

sub(10, 3)

Result: 7

Multiply numbers

Multiply two numbers together.

mul(4, 5)

Result: 20

Divide numbers

Divide one number by another.

div(20, 4)

Result: 5

Get maximum value

Find the largest number in a set.

max(1, 5, 3, 9, 2)

Result: 9

Get minimum value

Find the smallest number in a set.

min(1, 5, 3, 9, 2)

Result: 1

Conversion Functions

Convert to integer

Convert a value to an integer number.

int('42')

Result: 42

Convert to float

Convert a value to a floating-point number.

float('3.14')

Result: 3.14

Convert to string

Convert a value to a string.

string(42)

Result: "42"

Convert to boolean

Convert a value to a boolean.

bool('true')

Result: true

Parse JSON

Parse a JSON string into an object.

json('{"name":"John"}')

Result: Object with name property

Encode URI component

URL-encode a string for use in URLs.

encodeUriComponent('hello world')

Result: hello%20world

Data Operations

Access object property

Get a property value from an object.

body('Get_item')?['Title']

Result: The Title field value

Safe property access

Access a property without error if it doesn't exist.

body('Get_item')?['OptionalField']

Result: Value or null

Get action output

Reference the output of a previous action.

outputs('Compose')

Result: Output of Compose action

Get trigger output

Access data from the flow trigger.

triggerBody()

Result: Trigger body content

Get workflow run ID

Get the unique identifier of the current flow run.

workflow().run.name

Result: Run ID string