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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Dev-001
Regular Visitor

Expression.Error:We cannot apply operator + to types Date and Number

Hi I keep the above error even after changing data type to Date.Trying to create a new custom column based on another column.

Screenshot 2025-01-21 142548.png

This was the excel formula
=IF(AND(AM2="M",OR(AL2="",AL2<TODAY()+1))," PCF","")
I created the power query(M Code) for this but it's throwing an error. 

Any ideas how I can get around this?

 

Many thanks for all help

4 REPLIES 4
Dev-001
Regular Visitor

Table.AddColumn(CBCEventcalc, "PCF Event calc", each if DateTime.From([PCF Event]) = DateTime.From("M") and DateTime.From([Estimated Pickup] = DateTime.From(null) or DateTime.From([Estimated Pickup]) <= Date.From(DateTime.LocalNow()))then
           "PCF"
       else
           "")
Even i tried this but still throwing error. Please provide some advice
Screenshot 2025-01-21 203243.pngScreenshot 2025-01-21 203327.png
Dev-001
Regular Visitor

Table.AddColumn(CBCEventcalc, "PCF Event calc", each if [PCF Event] = "M" and ([Estimated Pickup] = null or [Estimated Pickup] <= Date.From(DateTime.LocalNow()))then
           "PCF"
       else
           "")
It's still showing the  error as shown below
Screenshot 2025-01-21 202140.png
danextian
Super User
Super User

Hi @Dev-001 

Use Date.AddDays(Date.From(DateTime.LocalNow()), 1)

 

Note: Power BI Servie uses UTC so take that into consideration when using functions that gets the current time. I use the formula below to convert a UTC date to my current time zone.

Date.From(DateTime.From(DateTimeZone.RemoveZone(DateTimeZone.UtcNow()) + #duration(0,8,0,0)))
//replace +/8 with your UTC offset




Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
johnt75
Super User
Super User

Rather than checking < today + 1 do a check for <= today.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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