Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Solved! Go to Solution.
COALESCE equivalent is available indeed through ?? operator, found here here after posting Q
= Table.AddColumn(#"Changed Type", "division", each [Numerator]/[Denominator] ?? 0)
COALESCE equivalent is available indeed through ?? operator, found here here after posting Q
= Table.AddColumn(#"Changed Type", "division", each [Numerator]/[Denominator] ?? 0)
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.