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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Atinder
Helper III
Helper III

Add IF date formula in the custom date

Hello, 

I want to add a custom date column in the table by using IF function. 

 

I want to see what items I received today by the posting date. 

 

= Table.AddColumn(#"Expanded PostedPO", "Custom", each if [PostedPO.Posting_Date] >= #date(today()) then "yes" else null)

1 ACCEPTED SOLUTION

My bad, I used the wrong syntax.

 

How about this:

= Table.AddColumn(#"Changed Type", "Custom", each if [PostedPO.Posting_Date] >= Date.AddDays(Date.From(DateTime.LocalNow()), - 1) then "yes" else null)

 

/Tom

https://www.tackytech.blog

https://www.instagram.com/tackytechtom



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

11 REPLIES 11
tackytechtom
Super User
Super User

Hi @Atinder ,

 

Does it work that way?

Table.AddColumn(#"Expanded PostedPO", "Custom", each if [PostedPO.Posting_Date] >= Date.AddDays(DateTime.LocalNow(),-1)) then "yes" else null)

 

Let me know!

 

/Tom

https://www.tackytech.blog

https://www.instagram.com/tackytechtom



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Hi@Tom,

 

No, I am getting this error.

 

Atinder_0-1644256309900.png

 

 

In the 'Custom Column' box you just need to enter this part...

if [PostedPO.Posting_Date] >= Date.AddDays(DateTime.LocalNow(),-1)) then "yes" else null

 

Not from the "Table.AddColumn...."

 

If this works, please accept Tom's answer as the solution, not this one.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

I am also getting this error

Atinder_0-1644267075509.png

 

Apologies, I copied the wrong text from @tackytechtom's answer. Use the below instead.  

Again, please accept Tom's answer if this solves your problem.

if [PostedPO.Posting_Date] >= Date.AddDays(Date.From(DateTime.LocalNow()), - 1) then "yes" else null

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

hi@KNP

 

i am getting this error.

Atinder_0-1644265919915.png

 

My bad, I used the wrong syntax.

 

How about this:

= Table.AddColumn(#"Changed Type", "Custom", each if [PostedPO.Posting_Date] >= Date.AddDays(Date.From(DateTime.LocalNow()), - 1) then "yes" else null)

 

/Tom

https://www.tackytech.blog

https://www.instagram.com/tackytechtom



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

tackytechtom
Super User
Super User

Hi @Atinder ,

 

how about this:

Date.AddDays(DateTime.LocalNow(),-1)

 

/Tom

https://www.tackytech.blog

https://www.instagram.com/tackytechtom

 



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Hi@Tom,

 

I am getting error but this message pops up when I put -1. 

 

Atinder_1-1644248359454.png

 

Atinder_0-1644248262692.png

 

tackytechtom
Super User
Super User

Hi @Atinder ,

 

This code snippet might help you:

Table.AddColumn(#"Expanded PostedPO", "Custom", each if [PostedPO.Posting_Date] >= Date.From(DateTime.LocalNow()) then "yes" else null)

 

Let me know!

 

/Tom

https://www.tackytech.blog

https://www.instagram.com/tackytechtom





Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Hi@Tom,

 

Solution works. How can I look yesterday's posting date. I tried to put -1 after now()-1 but it is not working.

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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 Kudoed Authors