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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Memorable Member
Memorable Member

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)

View solution in original post

3 REPLIES 3
Omid_Motamedise
Memorable Member
Memorable Member

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)

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. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.