#PowerPlatformTip 33: 'Coalesce in Power Apps'
How to use Coalesce in Power Apps and Power Automate: syntax, copy-paste examples, Coalesce vs. If(IsBlank()) and the coalesce() expression for flows.
TL;DR:
Coalescereturns the first non-blank value from a list of parameters – the one-line replacement for nestedIf(IsBlank())checks in Power Apps, and available ascoalesce()in Power Automate.
💡 Challenge
In PowerApps and Power Automate, managing multiple potential blank values often results in complex, nested If statements. This complexity hinders readability and efficiency.
✅ Solution
Implement the Coalesce function. It scans through a list of parameters and returns the first non-blank value, significantly simplifying formula complexity.
🧩 PowerApps Coalesce: Syntax and Examples
Coalesce( Value1 [, Value2, ... ] )
// Returns the nickname, otherwise the first name, otherwise "Unknown"
Coalesce( txtNickname.Text, txtFirstName.Text, "Unknown" )
// Fallback when a SharePoint column is blank
Coalesce( ThisItem.DisplayName, ThisItem.Title )
// Label with a default for empty lookup values
Coalesce( LookUp(Employees, ID = varID).Email, "no-email@company.com" )
Power Automate equivalent – the coalesce() expression works similarly in flows, but it skips only null, not empty strings (see the empty-string difference below):
1
coalesce(triggerBody()?['email'], variables('fallbackEmail'), 'noreply@example.com')
⚖️ Coalesce vs. If(IsBlank())
| Approach | Formula | Drawback |
|---|---|---|
| Nested If | If(!IsBlank(a), a, If(!IsBlank(b), b, c)) | Every value appears twice, hard to read with 3+ fallbacks |
| Coalesce | Coalesce(a, b, c) | None for stable values and a non-blank last fallback – one function call; see the note below for the last argument |
For stable values and a non-blank last fallback both return the same result. Coalesce(a, b) is the short form of If(!IsBlank(a), a, b) – each value is only written (and evaluated) once, while the If version writes a twice. The two differ when the last value is itself blank: Coalesce(Blank(), "") returns Blank(), but If(!IsBlank(Blank()), Blank(), "") returns the last operand "" unchanged. If the last fallback can be blank, check it as well.
🔀 Power Fx Coalesce vs. Power Automate coalesce(): the Empty-String Difference
Same name, one important difference: Power Fx treats "" as blank, the flow expression does not. Both columns were observed, Power Fx via pac power-fx run, the flow expressions in a Compose action.
| Case | Power Fx (Power Apps) | Power Automate expression |
|---|---|---|
| Empty string first | Coalesce("", "x") → "x" | coalesce('', 'x') → '' |
| null then empty string | Coalesce(Blank(), "") → Blank() | coalesce(null, '') → '' |
| Space | Coalesce(" ", "x") → " " | coalesce(' ', 'x') → ' ' |
| Zero | Coalesce(0, 5) → 0 | coalesce(0, 5) → 0 |
| false | Coalesce(false, true) → false | coalesce(false, true) → false |
| Several empties | Coalesce("", "", "y") → "y" | coalesce(null, '', 'x') → '' |
| All blank | Coalesce(Blank(), Blank()) → blank | coalesce(null, null) → null |
| Missing property | – | coalesce(triggerBody()?['missing'], 'x') → 'x' |
| Property with null value | – | coalesce(triggerBody()?['nullProp'], 'x') → 'x' |
🔸 In Power Fx IsBlank("") is true, so Coalesce skips empty strings and stops at the first value that is neither blank nor "".
🔸 In Power Automate coalesce() only skips null. An empty string is a value and gets returned, which is exactly what you get from an empty form field or an empty SharePoint text column.
🔸 Flow fallback that also covers '':
1
if(empty(coalesce(triggerBody()?['field'], '')), 'fallback', triggerBody()?['field'])
With "field": "" this returned fallback; empty() is true for null, a missing property and ''.
🔧 How It’s Done
-
Instead of using multiple nested If statements to check each value, list the values as parameters in the Coalesce function.
-
The function evaluates each parameter in order and returns the first non-blank value it encounters.
🎉 Result
This streamlines your formulas, making them easier to read and maintain, improving both development and future maintenance of the app or flow.
🌟 Key Advantages
🔸 Enhanced readability.
🔸 Reduced complexity.
🔸 Easier maintenance.
🔸 Improved performance in certain scenarios.
🎥 Video Tutorial
🛠️ FAQ
1. What is the difference between Coalesce and If(IsBlank())?
Coalesce(a, b) is the short form of If(!IsBlank(a), a, b) – same result for stable values and a non-blank last fallback, but each value is only written once. With several fallbacks this keeps formulas dramatically shorter and less error-prone.
2. Does Coalesce exist in Power Automate?
Yes, as the expression coalesce(), e.g. coalesce(triggerBody()?['email'], 'noreply@example.com'). It returns the first non-null parameter. Unlike Power Fx it does not skip empty strings: coalesce('', 'x') returns ''.
3. How many parameters can I pass to the Coalesce function?
There is no small fixed limit documented for Coalesce. Use as many values as needed, but keep formulas readable and use compatible types.
4. Does Coalesce work with different data types?
Yes, but ensure all parameters are compatible data types or use conversion functions like Text() or Value() when needed.
5. What’s considered a “blank” value in Coalesce?
In Power Fx: empty strings (“”), null values and the Blank() function result are skipped, Coalesce("", "x") returns "x". In Power Automate only null is skipped, coalesce('', 'x') returns ''. In both, zero (0) and false are not considered blank.
6. How do I make coalesce() in Power Automate skip empty strings?
Wrap it in an empty() check: if(empty(coalesce(triggerBody()?['field'], '')), 'fallback', triggerBody()?['field']). Replace triggerBody()?['field'] with your own value, for example a text field of the trigger. This returns the fallback for null, a missing property and an empty string. empty() works on strings, arrays and objects (Microsoft Learn), so for a number or a boolean use coalesce() alone and treat 0 or false as real values.
🔗 Related Tips
🔸 #PowerPlatformTip 136: ‘Patch + Coalesce Upsert’ - combine Coalesce() with Patch() to create and update records in a single call.
🔸 #PowerPlatformTip 23: ‘Filter Blank’ - a related IsBlank()-based pattern for gallery filters, worth comparing with Coalesce.
This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy, which runs free live workshops (in German). See the next free workshop dates (in German). For companies that want this implemented for them, see KMUpower: Power Platform consulting & automation for SMEs (DACH).