Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I am trying to use today's date to subtract from a column in power query that is a Due Date. There could be a null value in the Due Date column.
My formula is if Date.From(DateTime.LocalNow()) - [DueDate] <=0 then "OnTime" else Date.From(DateTime.LocalNow()) - [DueDate]
It says No Syntax Errors have been detected but the results in the column are errors. The error says Expression.Error: We cannot apply operator < to types Number and Duration.
Details:
Operator=<
Left=0
Right=847.00:00:00
Solved! Go to Solution.
Hi @dferry ,
Try this instead:
if [DueDate] = null then null
else if Date.From(DateTime.LocalNow()) < [DueDate] then "OnTime"
else Text.From(
Number.From(
Duration.Days(Date.From(DateTime.LocalNow()) - [DueDate])
)
)
You may need to fiddle with the final escape clause to get the exact output format you want, but the first two conditions should solve your isue.
Pete
Proud to be a Datanaut!
Hi @dferry ,
Try this instead:
if [DueDate] = null then null
else if Date.From(DateTime.LocalNow()) < [DueDate] then "OnTime"
else Text.From(
Number.From(
Duration.Days(Date.From(DateTime.LocalNow()) - [DueDate])
)
)
You may need to fiddle with the final escape clause to get the exact output format you want, but the first two conditions should solve your isue.
Pete
Proud to be a Datanaut!
Kudos Pete. That worked. Thank you very much.
Doug
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.