Skip to content

Power Automate Coalesce Function Explained

Power Automate Coalesce Function

The Power Automate Coalesce function is a less known function in Power Automate, but it is worth knowing the function.

It’s for example quite common to check if a value is null and in case it is null, you want to assign a certain value. So basically a fallback value or a default value. In an if statement you would do something like this:

if(equals(variables('color'),null),'white',variables('color'))

You can implement the same logic in a shorter more elegant variant by using coalesce function in Power Automate.

coalesce(variables('color'),'white')

Note that the function gets even more elegant in contrast to an if expression, when you have to check multiple values for null.

coalesce(variables('color1'),variables('color2'),variables('color3'),'white')

Let’s take a closer look at the coalesce function and see it in action within a flow!

Power Automate Coalesce Function
  1. Power Automate Coalesce Function
    • Syntax
    • Power Automate Coalesce Expression Examples
  2. How To Use The Coalesce Function In Power Automate

Power Automate Coalesce Function

The Power Automate coalesce function returns the first non-null item of a given list of parameters.

Syntax

coalesce(<object_1>, <object_2>, ...)

Input parameters

  • object_1 (mandatory): An object of any type that is checked if it is non-null.
  • object_2,.. (optional): One or more additional objects of any type that are checked, if they are non-null.

Return value

  • The first non-null value of the given parameters.
  • Null, if there is no non-null parameter.

Power Automate Coalesce Expression Examples

Power Automate Coalesce integer example

Since the coalesce function returns the first non-null value, in the example below a 1 is returned.

coalesce(null,1,2)
=> 1

Power Automate Coalesce String example

This is coalesce function example shows, that an empty string is not a null value. Therefore the return value in the example is the empty string.

coalesce('','abc')
=> ''

Power Automate Coalesce mixed types example

This one was a little surprise to me, you can actually mix different types within coalesce parameters. In the following example we use a string and a number.

coalesce(null,'a',1)
=> 'a'

Power Automate Coalesce array example

This example demonstrates that the Power Automate coalesce function works with arrays aswell.

coalesce(null,createArray(1,2,3),createArray('a','b'))
=> [1,2,3]

How To Use The Coalesce Function In Power Automate

Let’s create step-by-step a Microsoft flow that demonstrates the Power Automate coalesce function.

  1. Create a new instant cloud flow

    Power Automate Coalesce Function New Flow

    New cloud flow

  2. Add an ‘Initialize variable’ step, set Name to ‘myObject’ (1) and Type to ‘Object’ () and leave Value empty.

    Power Automate Coalesce Function initialize variable

    Create null object

  3. Add a Compose step and set Inputs to the expression ‘coalesce(variables(‘myObject’),’default’)’

    Power Automate Coalesce Expression 1

    Power Automate Coalesce Expression

  4. Do a test run and check the result

    Power Automate Coalesce Test Run

    Test run result: default

Note: You have to use a variable of type object for this example. String variables always get converted to empty strings, if you do not set them or even when you explicitly set them to null. (Feels wrong to me) For numbers it is the same, they get set to 0.

Leave a Comment Cancel Reply

Your email address will not be published. Required fields are marked *

玻璃钢生产厂家玻璃钢雕塑就找蓝眼泪玻璃钢剪纸雕塑怎样制作信阳景观玻璃钢卡通雕塑定制厂家洛阳商场美陈布置清远主题玻璃钢雕塑批发报价玻璃钢雕塑上青铜色太湖石玻璃钢景观雕塑定做做玻璃钢雕塑品牌安徽城市雕塑玻璃钢淮安五一商场美陈恩施玻璃钢雕塑考拉厂家六安欧式玻璃钢雕塑定制安阳玻璃钢伟人雕塑加工价格广东玻璃钢动物雕塑定做浙江商场创意商业美陈作品大连卡通玻璃钢雕塑厂德惠阳台玻璃钢花盆商丘玻璃钢浮雕城市雕塑广州玻璃钢花盆生产厂家马鞍山frp玻璃钢雕塑江西玻璃钢鸵鸟雕塑开县玻璃钢景观雕塑临沂公园玻璃钢雕塑价格天津商场主题创意商业美陈哪家好玻璃钢雕塑发光广东园林玻璃钢雕塑价格三水园林玻璃钢人物雕塑商场美陈方案要怎么排版公园水景玻璃钢卡通雕塑定制鹤岗玻璃钢雕塑厂家香港通过《维护国家安全条例》两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”19岁小伙救下5人后溺亡 多方发声单亲妈妈陷入热恋 14岁儿子报警汪小菲曝离婚始末遭遇山火的松茸之乡雅江山火三名扑火人员牺牲系谣言何赛飞追着代拍打萧美琴窜访捷克 外交部回应卫健委通报少年有偿捐血浆16次猝死手机成瘾是影响睡眠质量重要因素高校汽车撞人致3死16伤 司机系学生315晚会后胖东来又人满为患了小米汽车超级工厂正式揭幕中国拥有亿元资产的家庭达13.3万户周杰伦一审败诉网易男孩8年未见母亲被告知被遗忘许家印被限制高消费饲养员用铁锨驱打大熊猫被辞退男子被猫抓伤后确诊“猫抓病”特朗普无法缴纳4.54亿美元罚金倪萍分享减重40斤方法联合利华开始重组张家界的山上“长”满了韩国人?张立群任西安交通大学校长杨倩无缘巴黎奥运“重生之我在北大当嫡校长”黑马情侣提车了专访95后高颜值猪保姆考生莫言也上北大硕士复试名单了网友洛杉矶偶遇贾玲专家建议不必谈骨泥色变沉迷短剧的人就像掉进了杀猪盘奥巴马现身唐宁街 黑色着装引猜测七年后宇文玥被薅头发捞上岸事业单位女子向同事水杯投不明物质凯特王妃现身!外出购物视频曝光河南驻马店通报西平中学跳楼事件王树国卸任西安交大校长 师生送别恒大被罚41.75亿到底怎么缴男子被流浪猫绊倒 投喂者赔24万房客欠租失踪 房东直发愁西双版纳热带植物园回应蜉蝣大爆发钱人豪晒法院裁定实锤抄袭外国人感慨凌晨的中国很安全胖东来员工每周单休无小长假白宫:哈马斯三号人物被杀测试车高速逃费 小米:已补缴老人退休金被冒领16年 金额超20万

玻璃钢生产厂家 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化