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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Peter_B
Regular Visitor

The data type time works with greater than and equal but are incompatible in the less than operator?

Hi,

 

i'm having problem with not being able to use the less than operator when counting rows and the selected column is in the TIME-format.

HH:mm:ss

 

> Works fine:

Measure = COUNTAX(FILTER('KPI';'KPI'[Created]>TIMEVALUE("17:00:00"));'KPI'[KPI])

 

= Works fine:

Measure = COUNTAX(FILTER('KPI';'KPI'[Created]=TIMEVALUE("17:00:00"));'KPI'[KPI])

 

< Does not work:

Measure = COUNTAX(FILTER('KPI';'KPI'[Created]<TIMEVALUE("17:00:00"));'KPI'[KPI])

 

Error message:

The data types datetime and time are incompatible in the less than operator.. The exception was raised by the IDbCommand interface.

 

Does anyone know how I can get the less than to work in the same manner as greater than or equal?

 

Regards,

Peter

1 REPLY 1
v-sihou-msft
Employee
Employee

@Peter_B

 

What's your data source?

 

As I know, this is a limitation for SQL Server 2012 or later version. To workaround this issue, I suggest you retrieve the time part from your datetime and directly compare the time values when using "less than" operator.

 

Measure  =
COUNTAX (
    FILTER (
        Table1,
        TIME ( HOUR ( KPI[Created] ), MINUTE ( KPI[Created] ), SECOND ( KPI[Created] ) )
            < TIMEVALUE ( "17:00:00" )
    ),
    KPI[KPI]
)

 

 

Regards,

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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