# Power Automate: coalesce() to Replace Null Values

> For the full documentation index, see https://250highstreet.com/llms.txt

> Use coalesce() in Power Automate to return the first value that is not null. Set a default for empty columns, chain fallbacks and avoid null errors.

Use coalesce(value1, value2, ...) to return the first value that is not null. It is the shortest way to give a flow a default when a column, a trigger field or an API result comes back empty.

## What does coalesce() do in Power Automate?

The function reads its values from left to right and returns the first one that is not null. If every value is null, it returns null. Example: coalesce(triggerOutputs()?\['body/Notes'\], 'No notes') returns the notes, or the text 'No notes' when the column is null.

Add it in a Compose action, in a dynamic content field (open the Expression tab) or in a Set variable action. You can pass two values or many.

## How do you set a default value for a null column?

Put the column first and the default last: coalesce(items('Apply_to_each')?\['Amount'\], 0). A blank Number column then counts as 0 in later math steps.

Use the safe-access form ?\['Amount'\] with the question mark. Without it, a missing property stops the flow before coalesce() can run. For the null type error that this prevents, see [invalid type, expected string but got null](/guides/power-automate-invalid-type-expected-string-but-got-null/).

## Does coalesce() treat an empty string as null?

No. An empty string '' is a value, not null, so coalesce() returns it. A SharePoint text column that a user cleared can arrive as an empty string. In that case coalesce() does not pick your default.

Use if(empty(value), 'default', value) when the value can be null or an empty string. The empty() function is true for both. See [condition field empty](/guides/power-automate-condition-field-empty/) for how blank fields behave in a Condition action.

## How do you chain several fallback values?

List the fallbacks in order of preference: coalesce(triggerOutputs()?\['body/PreferredName'\], triggerOutputs()?\['body/FirstName'\], 'Customer'). The flow returns the first one that has a value.

This replaces a nest of if() tests. It stays readable at five or six values, because each value sits on its own position in one function.

## Can coalesce() fix an expression that fails on null?

Yes, in many cases. Wrap the risky value first: length(coalesce(variables('items'), json('\[\]'))) returns 0 instead of an error when the variable is null. The same pattern works for text: toLower(coalesce(value, '')).

If the error text says the template language expression cannot be processed, read [InvalidTemplate errors](/guides/power-automate-invalidtemplate-unable-to-process-template-language-expressions/) to find which part of the expression fails.

## FAQ

### Is there a ?? operator in Power Automate?

No. Power Automate expressions have no null-coalescing operator. Use the coalesce() function.

### What does coalesce() return when all values are null?

It returns null. Add a final non-null value, such as 0 or a text, as the last argument to guarantee a result.

### Can the values have different types?

Yes, the function accepts any type. Keep them the same type in practice, so later steps do not fail on a text where they expect a number.

## Sources

- [Reference guide to workflow expression functions in Azure Logic Apps and Power Automate](https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference)
- [Use expressions in conditions in Power Automate](https://learn.microsoft.com/en-us/power-automate/use-expressions-in-conditions)

## Related guides

- [Fix "Invalid type. Expected String but got Null" in Power Automate](/guides/power-automate-invalid-type-expected-string-but-got-null/)
- [Power Automate condition to check if a field is empty](/guides/power-automate-condition-field-empty/)
- [Fix the InvalidTemplate error in Power Automate](/guides/power-automate-invalidtemplate-unable-to-process-template-language-expressions/)

Source: https://250highstreet.com/guides/power-automate-coalesce-default-value-null/
