#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 the same way in flows:
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 – same result, one function call |
Both return the same result. Coalesce(a, b) is simply the short form of If(!IsBlank(a), a, b) – each value is only written (and evaluated) once.
🔧 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.
🔗 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.
🎥 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, 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.
3. How many parameters can I pass to the Coalesce function?
Coalesce can handle multiple parameters, but for optimal performance and readability, limit to 5-10 parameters.
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?
Blank values include empty strings (“”), null values, and the Blank() function result. Zero (0) and false are not considered blank.
This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).