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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Expression Error: We cannot apply operator < to types Number and Duration

Hi there, I am getting the following error on the below query:

Express.Error: We cannot apply operator < to types Number and Duration.

Details:

Operator=<

Left=35

Right=571.00:00:00

 

Custom Column Query used:

= if ([Vulnerability_Test_Date] - [Vulnerability_Published_Date] >=35) and [Severity] = "Critical" then "Yes" else
if ([Vulnerability_Test_Date] - [Vulnerability_Published_Date] >=65) and [Severity] = "High" then "Yes" else if
([Vulnerability_Test_Date] - [Vulnerability_Published_Date] >=95) and [Severity] = "Medium" then "Yes" else "No"

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try to solve this problem with calculated columns.

Column =
IF (
    [Vulnerability_Test_Date] - [Vulnerability_Published_Date] >= 35
        && [Severity] = "Critical",
    "Yes",
    IF (
        [Vulnerability_Test_Date] - [Vulnerability_Published_Date] >= 65
            && [Severity] = "High",
        "Yes",
        IF (
            [Vulnerability_Test_Date] - [Vulnerability_Published_Date] >= 95
                && [Severity] = "Medium",
            "Yes",
            "No"
        )
    )
)

vzhangti_0-1645077918191.png

 

If you try to solve it in Power query custom column, you need to do type conversion.

if (Number.From([Vulnerability_Test_Date] - [Vulnerability_Published_Date]) >=35) and [Severity] = "Critical" then "Yes" else
if (Number.From([Vulnerability_Test_Date] - [Vulnerability_Published_Date])>=65) and [Severity] = "High" then "Yes" else if
(Number.From([Vulnerability_Test_Date] - [Vulnerability_Published_Date])>=95) and [Severity] = "Medium" then "Yes" else "No"

vzhangti_1-1645078415495.png

 

This is the relevant document, hope to help you:

https://docs.microsoft.com/powerquery-m/type-conversion 

vzhangti_2-1645078452472.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try to solve this problem with calculated columns.

Column =
IF (
    [Vulnerability_Test_Date] - [Vulnerability_Published_Date] >= 35
        && [Severity] = "Critical",
    "Yes",
    IF (
        [Vulnerability_Test_Date] - [Vulnerability_Published_Date] >= 65
            && [Severity] = "High",
        "Yes",
        IF (
            [Vulnerability_Test_Date] - [Vulnerability_Published_Date] >= 95
                && [Severity] = "Medium",
            "Yes",
            "No"
        )
    )
)

vzhangti_0-1645077918191.png

 

If you try to solve it in Power query custom column, you need to do type conversion.

if (Number.From([Vulnerability_Test_Date] - [Vulnerability_Published_Date]) >=35) and [Severity] = "Critical" then "Yes" else
if (Number.From([Vulnerability_Test_Date] - [Vulnerability_Published_Date])>=65) and [Severity] = "High" then "Yes" else if
(Number.From([Vulnerability_Test_Date] - [Vulnerability_Published_Date])>=95) and [Severity] = "Medium" then "Yes" else "No"

vzhangti_1-1645078415495.png

 

This is the relevant document, hope to help you:

https://docs.microsoft.com/powerquery-m/type-conversion 

vzhangti_2-1645078452472.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

bcdobbs
Community Champion
Community Champion

Try and cast the difference as an integer.

 

INT ( [Vulnerability_Test_Date] - [Vulnerability_Published_Date] )>=95

 

You might want to store the difference in a variable first as well .



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors