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
j_t0418
Frequent Visitor

Expression Error: < to Types Date and Number

I'm trying to add the below custom column formula to a query of mine, but am recieivng  [Expression.Error] We cannot apply operator < to types Date and Number

 

if [SupplierText]="X" and [Date]>= 5/23/17 and [Date]<=6/8/17 and [Number]=null then 0 else if [SupplierText]="X" and [Date]>= 5/23/17 and [Date]<=6/8/17 and [TypeText]="X" then [Number] else if [SupplierText]="X" and [Date]>= 5/23/17 and [Date]<=6/8/17 and [TypeText]="Y" then 0 else if [SupplierText]="X" and [Date]>= 5/23/17 and [Date]<=6/8/17 and [TypeText]="Z" then 0 else [Number2]

 

Any insight would be much appreciated!

1 ACCEPTED SOLUTION
v-huizhn-msft
Employee
Employee

Hi @j_t0418,

In your Query statement, 5/23/17  is recognised as text, please use #date(2017,5,23). Please use the following statement, and check if it works fine.


if [SupplierText]="X" and [Date]>= #date(2017,5,23) and [Date]<=#date(2017,6,8) and [Number]=null then 0 else if [SupplierText]="X" and [Date]>= #date(2017,5,23) and #date(2017,6,8) and [TypeText]="X" then [Number] else if [SupplierText]="X" and [Date]>= #date(2017,5,23) and #date(2017,6,8) and [TypeText]="Y" then 0 else if [SupplierText]="X" and [Date]>= #date(2017,5,23) and #date(2017,6,8) and [TypeText]="Z" then 0 else [Number2]


Best Regards,
Angelia

 

View solution in original post

3 REPLIES 3
v-huizhn-msft
Employee
Employee

Hi @j_t0418,

In your Query statement, 5/23/17  is recognised as text, please use #date(2017,5,23). Please use the following statement, and check if it works fine.


if [SupplierText]="X" and [Date]>= #date(2017,5,23) and [Date]<=#date(2017,6,8) and [Number]=null then 0 else if [SupplierText]="X" and [Date]>= #date(2017,5,23) and #date(2017,6,8) and [TypeText]="X" then [Number] else if [SupplierText]="X" and [Date]>= #date(2017,5,23) and #date(2017,6,8) and [TypeText]="Y" then 0 else if [SupplierText]="X" and [Date]>= #date(2017,5,23) and #date(2017,6,8) and [TypeText]="Z" then 0 else [Number2]


Best Regards,
Angelia

 

This solution worked seamelessly. Thank you for your help!

I have similar issue, and the advice posted in this forum didn`t help.

 

 


#"Changed Type" = Table.TransformColumnTypes(TIMEFACTSDAY1,{{"DAY", type date}}),
#"Filtered Rows" = Table.SelectRows(TIMEFACTSDAY1, each not List.Contains({129,1142},[USER_ID]) or [DAY] <= #date(2018, 1, 1))
in
#"Filtered Rows"

 

 

"we cannot apply operator to types date and datetime"

Where could be the problem please?

 

 

Thanks

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.