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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
caciliberti
New Member

change duration format to decimal

Hello

I am new to PowerBI and I added a custom column to calulate time with the following formula :

if [#"Priority Rating (DVP)"] = "Critical" and DateTime.Date( DateTime.LocalNow() )-[First Seen] <= 30 then "Within SLA" else "Outside SLA"

 

Priority Rating (DVP)First SeenSLA
Critical7/11/2024Error
Critical8/15/2024Error

 

And I get a "error" in the "SLA" column like this:

Expression.Error: We cannot apply operator < to types Number and Duration.
Details:
Operator=<
Left=30
Right=47.00:00:00

 

Can I include in the formula above the option to automatically convert the result expressed in duration into decimal instead of returning "error"? thanks. 

1 ACCEPTED SOLUTION
Omid_Motamedise
Super User
Super User

the problem is for the below condition

 DateTime.Date( DateTime.LocalNow() )-[First Seen] <= 30

in the left site of <= we have duration format in the right side we have number, change the number to duration by using #duration(30,0,0,0).
I also recomended to use the below formula for this part in some cases your format might be mismatch.


(Date.From( DateTime.LocalNow() )-Date.From([First Seen])) <= #duration(30,0,0,0)

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

View solution in original post

3 REPLIES 3
Omid_Motamedise
Super User
Super User

the problem is for the below condition

 DateTime.Date( DateTime.LocalNow() )-[First Seen] <= 30

in the left site of <= we have duration format in the right side we have number, change the number to duration by using #duration(30,0,0,0).
I also recomended to use the below formula for this part in some cases your format might be mismatch.


(Date.From( DateTime.LocalNow() )-Date.From([First Seen])) <= #duration(30,0,0,0)

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

This is very helpful, thank you vert much for the help!!

Your welcome, 
if it solve your problem, pls mark it as solution for the use of other users. 

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors