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
hobbssj
Regular Visitor

Trouble with calculated date column

Hello,
 
I'm trying to add a column to use in a visual. The column will be displaying one of two options if the date in the "modidate" is 3 days prior to the current date.
 
The modidate contains a datatime data type. and is contained in the tasks table
 
ticketupdated = IF(DATEDIFF(TASKS[MODIDATE];today();day); <3; True(UptoDate), False(Needs update))
 
With the above I am getting a sytax error as well as a pop up message that says cannot find modidate.
 
I figure I'm refrencing the SQL data wrong, but I'm not sure how to fix it, can anyone advise? or suggest a better way to do this?
1 ACCEPTED SOLUTION

Hi, @hobbssj 

 

You need to modify your code,Like this:

= Table.AddColumn(#"Sorted Rows1", "ticketupdated", each if Date.From([date])>=Date.AddDays( Date.From(DateTime.LocalNow()),-3) and Date.From([date])<Date.From(DateTime.LocalNow())
then true 
else false)

2.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

4 REPLIES 4
amitchandak
Super User
Super User

@hobbssj , this can be like

ticketupdated = IF(DATEDIFF(TASKS[MODIDATE],today(),day) <3, True(), False())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks,

 

That made a difference  however its still not working 

I added this to the custom column and it came out like this 

 

= Table.AddColumn(#"Sorted Rows1", "ticketupdated", each ticketupdated = IF(DATEDIFF(TASKS[MODIDATE],today(),day) <3, True(), False()))

 

and got 

Expression.Error: The name 'ticketupdated' wasn't recognized. Make sure it's spelled correctly.

 

I adjusted it 

 

= Table.AddColumn(#"Sorted Rows1", "ticketupdated", IF(DATEDIFF(TASKS[MODIDATE],today(),day) <3, True(), False()))

 

and now am getting 

 

Expression.Error: The name 'IF' wasn't recognized. Make sure it's spelled correctly

 

any thoughts?

Hi, @hobbssj 

 

You need to modify your code,Like this:

= Table.AddColumn(#"Sorted Rows1", "ticketupdated", each if Date.From([date])>=Date.AddDays( Date.From(DateTime.LocalNow()),-3) and Date.From([date])<Date.From(DateTime.LocalNow())
then true 
else false)

2.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

Just a quick update, we ended up getting our DBA to create a custom view on on the database. 

 

but I testted the Janey's soltuion and that worked as well 

 

Thanks for everyone help

 

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