Post

#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.

#PowerPlatformTip 33: 'Coalesce in Power Apps'

TL;DR: Coalesce returns the first non-blank value from a list of parameters – the one-line replacement for nested If(IsBlank()) checks in Power Apps, and available as coalesce() 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.

🔀 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, 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?

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?

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(value, '')), 'fallback', value). This returns the fallback for null, a missing property and an empty string.

🔸 #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 – 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).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.