The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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 Seen | SLA |
Critical | 7/11/2024 | Error |
Critical | 8/15/2024 | Error |
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.
Solved! Go to Solution.
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)
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.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.