Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
smpa01
Super User
Super User

Does PQ have any one liner syntax equivalent to SQL's COALESCE

Is there any built-in one liner syntax avaialble in PQ that is similar to SQL's COALESCE?

 

 

 

 

//PQ
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjFV0lHKK83JgVGxOtFKIGEzoIChAZAwBQuBRMxBQoZwhbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [test = _t, Numerator = _t, Denominator = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"test", Int64.Type}, {"Numerator", Int64.Type}, {"Denominator", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "division", each try [Numerator]/[Denominator] otherwise 0)
in
    #"Added Custom"

//SQL
declare @t1 as table (test integer, numerator integer, denominator integer)
insert into @t1

select * from
(values(12345,null,null),(23456,10,5),(34567,11,null)) t(a,b,c)

select *, COALESCE( (numerator/denominator),0)  as divison
from
@t1

 

 

 

 

smpa01_0-1660063769702.png

 

smpa01_1-1660063797327.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION
smpa01
Super User
Super User

COALESCE equivalent is available indeed through ?? operator, found here here after posting Q

 

smpa01_0-1660064178345.png

 

 

= Table.AddColumn(#"Changed Type", "division", each [Numerator]/[Denominator] ?? 0)

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

1 REPLY 1
smpa01
Super User
Super User

COALESCE equivalent is available indeed through ?? operator, found here here after posting Q

 

smpa01_0-1660064178345.png

 

 

= Table.AddColumn(#"Changed Type", "division", each [Numerator]/[Denominator] ?? 0)

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.